gulp-js2json

1.0.1 • Public • Published

gulp-js2json

Convert js format to json format, mainly because line breaks in json format are cumbersome

Install

npm install --save-dev gulp-js2json

Usage

Transform example.css:

xxxxxx //Some logical processing
module.exports = {
  title:"example",
  content:`A long long long long long long long long and
    broken paragraph`,
  content2:'A long long long long long long long long and'+
  'non-breaking paragraph'
} 

Into example.json:

{
  "title":"example",
  "content":"A long long long long long long long long and\n      broken paragraph",
  "content2":"A long long long long long long long long andnon-breaking paragraph"
}

Using gulpfile.js:

var gulp = require('gulp');
var file2json = require('gulp-js2json');

gulp.task('js-json', function () {
  return gulp.src('example/example.js')
    .pipe(js2json())
    .pipe(gulp.dest('example'));
});

Credits

Inspired by gulp-file-to-json (Gulp plugin to convert a file and its MD5 hash value into a JSON representation,Obviously, I just copied this project and modified a few lines of code.).

License

MIT © 2016 Vast.com, Inc.

Package Sidebar

Install

npm i gulp-js2json

Weekly Downloads

5

Version

1.0.1

License

ISC

Unpacked Size

4.36 kB

Total Files

7

Last publish

Collaborators

  • beifeng