| const gulp = require('gulp') | ||
| const gcson = require('../') | ||
| gulp.task('cson', () => { | ||
| gulp.src('./normal.cson') | ||
| .pipe(gcson()) | ||
| .pipe(gulp.dest('./')) | ||
| }) | ||
| gulp.task('default', ['cson']) |
+65
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const should = require('should'); | ||
| const gutil = require('gulp-util'); | ||
| const gcson = require('../'); | ||
| require('mocha'); | ||
| describe('gulp-cson', function() { | ||
| it('should parse cson to json', function(done) { | ||
| const myFunction = gcson({ | ||
| indent: null | ||
| }); | ||
| const 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', function(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.json')))); | ||
| return done(); | ||
| }); | ||
| return myFunction.write(fakeFile); | ||
| }); | ||
| it('should parse cson to json with indent', function(done) { | ||
| const myFunction = gcson(); | ||
| const 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', function(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')))); | ||
| return done(); | ||
| }); | ||
| return myFunction.write(fakeFile); | ||
| }); | ||
| return it('should return error on error', function(done) { | ||
| const myFunction = gcson(); | ||
| const fakeFile = new gutil.File({ | ||
| base: 'test/fixtures', | ||
| cwd: 'test/', | ||
| path: 'test/fixtures/normal.cson', | ||
| contents: fs.readFileSync(path.join(__dirname, '/fixtures/error.cson')) | ||
| }); | ||
| myFunction.once('error', function(err) { | ||
| should.exist(err); | ||
| should.equal(err.name, 'SyntaxError'); | ||
| should.equal(err.message, 'unmatched }'); | ||
| return done(); | ||
| }); | ||
| return myFunction.write(fakeFile); | ||
| }); | ||
| }); | ||
| // --- | ||
| // generated by coffee-script 1.9.2 |
+2
-3
| sudo: false | ||
| language: node_js | ||
| node_js: | ||
| - "iojs" | ||
| - "0.10" | ||
| - "0.12" | ||
| - "lts/*" | ||
| - "node" |
+23
-2
@@ -1,2 +0,23 @@ | ||
| require('coffee-script/register'); | ||
| module.exports = require('./index.coffee'); | ||
| const map = require("map-stream"); | ||
| const rext = require("replace-ext"); | ||
| const cson = require("cson"); | ||
| module.exports = function (options) { | ||
| if (!options) { | ||
| options = {}; | ||
| } | ||
| const indent = | ||
| typeof options.indent === "string" || options.indent === null | ||
| ? options.indent | ||
| : " "; | ||
| const gcson = function (file, cb) { | ||
| const json = cson.parse(file.contents.toString(), options); | ||
| if (json instanceof Error) { | ||
| return cb(json); | ||
| } | ||
| file.contents = new Buffer(JSON.stringify(json, null, indent)); | ||
| file.path = rext(file.path, ".json"); | ||
| return cb(null, file); | ||
| }; | ||
| return map(gcson); | ||
| }; |
+5
-6
| { | ||
| "name": "gulp-cson", | ||
| "description": "Parse cson with gulp", | ||
| "version": "0.4.0", | ||
| "version": "1.0.0", | ||
| "homepage": "http://github.com/stevelacy/gulp-cson", | ||
@@ -13,6 +13,5 @@ "repository": { | ||
| "dependencies": { | ||
| "coffee-script": "^1.9.1", | ||
| "cson": "^3.0.1", | ||
| "map-stream": "^0.1.0", | ||
| "replace-ext": "0.0.1" | ||
| "cson": "^7.5.0", | ||
| "map-stream": "^0.0.7", | ||
| "replace-ext": "2.0.0" | ||
| }, | ||
@@ -25,3 +24,3 @@ "devDependencies": { | ||
| "scripts": { | ||
| "test": "mocha --compilers coffee:coffee-script/register --reporter spec" | ||
| "test": "mocha --reporter spec" | ||
| }, | ||
@@ -28,0 +27,0 @@ "engines": { |
+10
-40
@@ -32,47 +32,17 @@ #gulp-cson | ||
| ``` | ||
| ##Example | ||
| ## Example | ||
| ```js | ||
| const gulp = require('gulp') | ||
| const gcson = require('../') | ||
| #### Default indentation (2 spaces) | ||
| ```coffee-script | ||
| gulp = require 'gulp' | ||
| gcson = require 'gulp-cson' | ||
| gulp.task('cson', () => { | ||
| gulp.src('./normal.cson') | ||
| .pipe(gcson()) | ||
| .pipe(gulp.dest('./')) | ||
| }) | ||
| gulp.task 'cson', -> | ||
| gulp.src './normal.cson' | ||
| .pipe gcson() | ||
| .pipe gulp.dest './' | ||
| gulp.task 'default', ['cson'] | ||
| gulp.task('default', ['cson']) | ||
| ``` | ||
| #### 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) | ||
@@ -79,0 +49,0 @@ |
Sorry, the diff of this file is not supported yet
| gulp = require 'gulp' | ||
| gcson = require '../' | ||
| gulp.task 'cson', -> | ||
| gulp.src './normal.cson' | ||
| .pipe gcson() | ||
| .pipe gulp.dest './' | ||
| gulp.task 'default', ['cson'] |
-18
| map = require 'map-stream' | ||
| coffee = require 'coffee-script' | ||
| rext = require 'replace-ext' | ||
| cson = require 'cson' | ||
| module.exports = (options) -> | ||
| options = {} unless options | ||
| indent = if typeof options.indent == 'string' or options.indent == null then options.indent else ' ' | ||
| gcson = (file, cb) -> | ||
| json = cson.parse file.contents.toString(), options | ||
| return cb json if json instanceof Error | ||
| file.contents = new Buffer JSON.stringify json, null, indent | ||
| file.path = rext file.path, '.json' | ||
| cb null, file | ||
| return map gcson |
| fs = require 'fs' | ||
| path = require 'path' | ||
| should = require 'should' | ||
| gutil = require 'gulp-util' | ||
| gcson = require '../' | ||
| require 'mocha' | ||
| describe 'gulp-cson', -> | ||
| it 'should parse cson to json', (done) -> | ||
| myFunction = gcson( | ||
| indent: null | ||
| ) | ||
| 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.json' | ||
| done() | ||
| myFunction.write fakeFile | ||
| 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) -> | ||
| myFunction = gcson() | ||
| fakeFile = new gutil.File | ||
| base: 'test/fixtures' | ||
| cwd: 'test/' | ||
| path: 'test/fixtures/normal.cson' | ||
| contents: fs.readFileSync path.join __dirname, '/fixtures/error.cson' | ||
| myFunction.once 'error', (err) -> | ||
| should.exist err | ||
| should.equal err.name, 'SyntaxError' | ||
| should.equal err.message, 'unmatched }' | ||
| done() | ||
| myFunction.write fakeFile |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
3
-25%101
818.18%0
-100%7373
-4.41%13
-13.33%75
-28.57%2
100%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated