| { | ||
| "abc": [ | ||
| "a", | ||
| "b", | ||
| "c" | ||
| ], | ||
| "a": { | ||
| "b": "c" | ||
| } | ||
| } |
+2
-1
@@ -8,2 +8,3 @@ map = require 'map-stream' | ||
| options = {} unless options | ||
| indent = if typeof options.indent == 'string' or options.indent == null then options.indent else ' ' | ||
@@ -13,3 +14,3 @@ gcson = (file, cb) -> | ||
| return cb json if json instanceof Error | ||
| file.contents = new Buffer JSON.stringify json | ||
| file.contents = new Buffer JSON.stringify json, null, indent | ||
| file.path = rext file.path, '.json' | ||
@@ -16,0 +17,0 @@ |
+1
-1
| { | ||
| "name": "gulp-cson", | ||
| "description": "Parse cson with gulp", | ||
| "version": "0.3.1", | ||
| "version": "0.4.0", | ||
| "homepage": "http://github.com/stevelacy/gulp-cson", | ||
@@ -6,0 +6,0 @@ "repository": { |
+31
-0
@@ -34,2 +34,3 @@ #gulp-cson | ||
| #### Default indentation (2 spaces) | ||
| ```coffee-script | ||
@@ -47,2 +48,32 @@ gulp = require 'gulp' | ||
| #### No indentation | ||
| ```coffee-script | ||
| gulp = require 'gulp' | ||
| gcson = require 'gulp-cson' | ||
| gulp.task 'cson', -> | ||
| gulp.src './normal.cson' | ||
| .pipe gcson( | ||
| indent: null | ||
| ) | ||
| .pipe gulp.dest './' | ||
| gulp.task 'default', ['cson'] | ||
| ``` | ||
| #### With custom indentation | ||
| ```coffee | ||
| gulp = require 'gulp' | ||
| gcson = require 'gulp-cson' | ||
| gulp.task 'cson', -> | ||
| gulp.src './normal.cson' | ||
| .pipe gcson( | ||
| indent: '\t' | ||
| ) | ||
| .pipe gulp.dest './' | ||
| gulp.task 'default', ['cson'] | ||
| ``` | ||
| ####You can view more examples in the [example folder.](https://github.com/stevelacy/gulp-cson/tree/master/examples) | ||
@@ -49,0 +80,0 @@ |
+21
-2
@@ -11,3 +11,5 @@ fs = require 'fs' | ||
| it 'should parse cson to json', (done) -> | ||
| myFunction = gcson() | ||
| myFunction = gcson( | ||
| indent: null | ||
| ) | ||
| fakeFile = new gutil.File | ||
@@ -22,3 +24,3 @@ base: 'test/fixtures' | ||
| should.exist newFile.contents | ||
| should.equal newFile.path, 'test/fixtures/normal.json' | ||
| should.equal newFile.path.replace(/\\/g, '/'), 'test/fixtures/normal.json' | ||
| String(newFile.contents).should.equal String fs.readFileSync path.join __dirname, '/expected/normal.json' | ||
@@ -29,2 +31,19 @@ done() | ||
| it 'should parse cson to json with indent', (done) -> | ||
| myFunction = gcson() | ||
| fakeFile = new gutil.File | ||
| base: 'test/fixtures' | ||
| cwd: 'test/' | ||
| path: 'test/fixtures/normal.cson' | ||
| contents: fs.readFileSync path.join __dirname, '/fixtures/normal.cson' | ||
| myFunction.once 'data', (newFile) -> | ||
| should.exist newFile | ||
| should.exist newFile.contents | ||
| should.equal newFile.path.replace(/\\/g, '/'), 'test/fixtures/normal.json' | ||
| String(newFile.contents).should.equal String fs.readFileSync path.join __dirname, '/expected/normal-indent.json' | ||
| done() | ||
| myFunction.write fakeFile | ||
| it 'should return error on error', (done) -> | ||
@@ -31,0 +50,0 @@ myFunction = gcson() |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
7713
21.68%15
7.14%11
450%105
41.89%0
-100%