gulp-decomment
Advanced tools
Comparing version 0.0.1 to 0.1.0
46
index.js
'use strict'; | ||
var through = require('through2'); | ||
var gutil = require('gulp-util'); | ||
var decomment = require('decomment'); | ||
var PluginError = gutil.PluginError; | ||
var PluginError = require('gulp-util').PluginError; | ||
var PLUGIN_NAME = 'gulp-decomment'; | ||
function gulpDecomment() { | ||
var stream = through.obj(function (file, enc, cb) { | ||
function main(options, func) { | ||
return through.obj(function (file, enc, cb) { | ||
if (file.isNull()) { | ||
@@ -18,32 +13,23 @@ cb(null, file); | ||
} | ||
if (file.isStream()) { | ||
cb(new PluginError(PLUGIN_NAME, 'Streaming not supported')); | ||
return; | ||
cb(new PluginError("gulp-decomment", "Streaming not supported.")); | ||
} | ||
/* | ||
if (noopt || (!block && !line)) { | ||
strip = stripComments; | ||
} else if (block && line) { | ||
this.emit('error', new PluginError(PLUGIN_NAME, 'Please choose either block or line, not both!')); | ||
} else if (block) { | ||
strip = stripComments.block; | ||
} else if (line) { | ||
strip = stripComments.line; | ||
} else { | ||
this.emit('error', new PluginError(PLUGIN_NAME, 'Please define options correctly')); | ||
} | ||
*/ | ||
if (file.isBuffer()) { | ||
file.contents = new Buffer(decomment(file.contents.toString())); | ||
} | ||
file.contents = new Buffer(func(file.contents.toString(), options)); | ||
this.push(file); | ||
return cb(); | ||
}); | ||
} | ||
return stream; | ||
function gulpDecomment(options) { | ||
return main(options, decomment); | ||
} | ||
gulpDecomment.text = function (options) { | ||
return main(options, decomment.text); | ||
}; | ||
gulpDecomment.html = function (options) { | ||
return main(options, decomment.html); | ||
}; | ||
module.exports = gulpDecomment; |
{ | ||
"name": "gulp-decomment", | ||
"version": "0.0.1", | ||
"description": "Removes comments from JSON or JavaScript.", | ||
"main": "lib/index.js", | ||
"version": "0.1.0", | ||
"description": "Removes comments from JSON, JavaScript, CSS, HTML, etc.", | ||
"scripts": { | ||
@@ -12,5 +11,14 @@ "test": "jasmine-node test", | ||
"files": [ | ||
"test", | ||
"index.js" | ||
], | ||
"dependencies": { | ||
"decomment": "0.7", | ||
"gulp-util": "3.0", | ||
"through2": "2.0" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "2.x", | ||
"istanbul": "0.4", | ||
"jasmine-node": "1.x" | ||
}, | ||
"homepage": "https://github.com/vitaly-t/gulp-decomment", | ||
@@ -28,3 +36,6 @@ "repository": { | ||
"JavaScript", | ||
"JSON" | ||
"JSON", | ||
"CSS", | ||
"HTML", | ||
"Text" | ||
], | ||
@@ -35,14 +46,3 @@ "author": { | ||
}, | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=0.10", | ||
"npm": ">=1.4" | ||
}, | ||
"dependencies": { | ||
}, | ||
"devDependencies": { | ||
"coveralls": "2.x", | ||
"istanbul": "0.4", | ||
"jasmine-node": "1.x" | ||
} | ||
"license": "MIT" | ||
} |
gulp-decomment | ||
============== | ||
Removes comments from JSON or JavaScript. | ||
Uses [decomment] to remove comments from JSON, JavaScript, CSS, HTML, etc. | ||
**This library is currently under development.** | ||
[![Build Status](https://travis-ci.org/vitaly-t/gulp-decomment.svg?branch=master)](https://travis-ci.org/vitaly-t/gulp-decomment) | ||
[![Coverage Status](https://coveralls.io/repos/vitaly-t/gulp-decomment/badge.svg?branch=master)](https://coveralls.io/r/vitaly-t/gulp-decomment?branch=master) | ||
## Installing | ||
``` | ||
$ npm install gulp-decomment | ||
``` | ||
## Testing | ||
``` | ||
$ npm test | ||
``` | ||
Testing with coverage: | ||
``` | ||
$ npm run coverage | ||
``` | ||
## Usage | ||
```js | ||
var gulp = require('gulp'); | ||
var decomment = require('gulp-decomment'); | ||
gulp.task('default', function () { | ||
return gulp.src('input.js') | ||
.pipe(decomment()) | ||
.pipe(gulp.dest('dest')); | ||
}); | ||
``` | ||
## API | ||
Available methods, according to [decomment API](https://github.com/vitaly-t/decomment#api): | ||
* [decomment([options])](https://github.com/vitaly-t/decomment#decommentcode-options--string) | ||
* [decomment.text([options])](https://github.com/vitaly-t/decomment#decommenttexttext-options--string) | ||
* [decomment.html([options])](https://github.com/vitaly-t/decomment#decommenthtmlhtml-options--string) | ||
## License | ||
Copyright © 2016 [Vitaly Tomilov](https://github.com/vitaly-t); | ||
Released under the MIT license. | ||
[decomment]:https://github.com/vitaly-t/decomment |
3473
52
3
3
28
+ Addeddecomment@0.7
+ Addedgulp-util@3.0
+ Addedthrough2@2.0
+ Addedansi-gray@0.1.1(transitive)
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedansi-wrap@0.1.0(transitive)
+ Addedarray-differ@1.0.0(transitive)
+ Addedarray-uniq@1.0.3(transitive)
+ Addedbeeper@1.1.1(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedclone@1.0.4(transitive)
+ Addedclone-stats@0.0.1(transitive)
+ Addedcolor-support@1.1.3(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddateformat@2.2.0(transitive)
+ Addeddecomment@0.7.5(transitive)
+ Addedduplexer2@0.0.2(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedesprima@2.7.3(transitive)
+ Addedfancy-log@1.3.3(transitive)
+ Addedglogg@1.0.2(transitive)
+ Addedgulp-util@3.0.8(transitive)
+ Addedgulplog@1.0.0(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedhas-gulplog@0.1.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisarray@0.0.11.0.0(transitive)
+ Addedlodash._basecopy@3.0.1(transitive)
+ Addedlodash._basetostring@3.0.1(transitive)
+ Addedlodash._basevalues@3.0.0(transitive)
+ Addedlodash._getnative@3.9.1(transitive)
+ Addedlodash._isiterateecall@3.0.9(transitive)
+ Addedlodash._reescape@3.0.0(transitive)
+ Addedlodash._reevaluate@3.0.0(transitive)
+ Addedlodash._reinterpolate@3.0.0(transitive)
+ Addedlodash._root@3.0.1(transitive)
+ Addedlodash.escape@3.2.0(transitive)
+ Addedlodash.isarguments@3.1.0(transitive)
+ Addedlodash.isarray@3.0.4(transitive)
+ Addedlodash.keys@3.1.2(transitive)
+ Addedlodash.restparam@3.6.1(transitive)
+ Addedlodash.template@3.6.2(transitive)
+ Addedlodash.templatesettings@3.1.1(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmultipipe@0.1.2(transitive)
+ Addedobject-assign@3.0.0(transitive)
+ Addedparse-node-version@1.0.1(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedreadable-stream@1.1.142.3.8(transitive)
+ Addedreplace-ext@0.0.1(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsparkles@1.0.1(transitive)
+ Addedstring_decoder@0.10.311.1.1(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addedthrough2@2.0.5(transitive)
+ Addedtime-stamp@1.1.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedvinyl@0.5.3(transitive)
+ Addedxtend@4.0.2(transitive)