Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

gulp-cson

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-cson - npm Package Compare versions

Comparing version
0.4.0
to
1.0.0
+10
examples/gulpfile.js
const gulp = require('gulp')
const gcson = require('../')
gulp.task('cson', () => {
gulp.src('./normal.cson')
.pipe(gcson())
.pipe(gulp.dest('./'))
})
gulp.task('default', ['cson'])
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);
};
{
"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']
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