gulp-js-to-json

1.1.2 • Public • Published

gulp-js-to-json

Install with npm install gulp-js-to-json

Accepts require-able javascript files, and attempts to stringify them as JSON.

Example

src (sample/sample.js):

module.exports = {
    'this': ['that','I','Can','be', 'executed'].join('\n'),
    tabs:['*tab','*tab',['*space', '*space'].join(' ')].join('\n'),
    complex:'this is ' +
    'my stuff' +
    'more ' +
    'words ' +
    'yo '
}

gulp task:

gulp.task('2JSON', function(){
   return gulp.src('sample/**/*.js', {read: false})
       .pipe(toJSON({
           stringify:{
               replacer: miscReplacer,
               space: '\t'
           }
       }))
       .pipe(gulp.dest('sample'));
});

result (sample/sample.json):

{"this":"that\nI\nCan\nbe\nexecuted","tabs":"*tab\n*tab\n*space *space","complex":"this is my stuffmore words yo "}

Test

Run tests with mocha test test/

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.2
    43
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.2
    43
  • 1.1.0
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i gulp-js-to-json

Weekly Downloads

43

Version

1.1.2

License

MIT

Last publish

Collaborators

  • ahoran3
  • tylerdixon