https://github.com/crissdev/gulp-props
Convert Java .properties to JSON
https://github.com/crissdev/gulp-props
Last synced: 11 months ago
JSON representation
Convert Java .properties to JSON
- Host: GitHub
- URL: https://github.com/crissdev/gulp-props
- Owner: crissdev
- License: mit
- Created: 2014-09-22T14:26:51.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2018-04-22T14:47:16.000Z (almost 8 years ago)
- Last Synced: 2025-04-11T16:37:17.767Z (11 months ago)
- Language: JavaScript
- Size: 43 KB
- Stars: 1
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# gulp-props
[](https://standardjs.com)
[](http://badge.fury.io/js/gulp-props)
[](https://travis-ci.org/crissdev/gulp-props)
[](https://ci.appveyor.com/project/crissdev/gulp-props/branch/master)
[](https://david-dm.org/crissdev/gulp-props)
> A [Gulp](https://github.com/gulpjs/gulp) plugin to convert [Java .properties](http://en.wikipedia.org/wiki/.properties) to [JSON](http://en.wikipedia.org/wiki/JSON)
## Install
```sh
npm install --save-dev gulp-props
```
## Usage
```js
const props = require('gulp-props');
// Generate a .js file with default namespace (config)
gulp.src('./src/*.properties')
.pipe(props())
.pipe(gulp.dest('./dist/'))
// Generate a .json file indented with 2 spaces
gulp.src('./src/*.properties')
.pipe(props({ namespace: '', space: 2 }))
.pipe(gulp.dest('./dist/'))
// Generate a .js file with a custom namespace (state)
gulp.src('./src/*.properties')
.pipe(props({ namespace: 'state' }))
.pipe(gulp.dest('./dist/'))
```
## API
### props([options])
#### options.namespace
Type: `String`
Default: `config`
The namespace to use when defining properties. Javascript reserved words cannot be used here.
Invalid identifiers will be adjusted to be valid, and a warning will be printed in the console.
**Note**: To force a `JSON` output set this option to an empty string.
#### options.space
Type: `Number` or `String`
Default: `null`
Control spacing in the resulting output. It has the same usage as for [JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
_The option is used only when namespace option is an empty string._
#### options.replacer
Type: `Function` or `Array`
Default: `null`
Further transform the resulting output. It has the same usage as for [JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
_The option is used only when namespace option is an empty string._
#### options.appendExt
Type: `Boolean`
Default: `false`
Append the extension (`.js` or `.json`) instead of replacing it.
Useful if the property file doesn't have an extension.
## License
MIT © [Cristian Trifan](https://crissdev.com)