gulp-strip-code
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -8,5 +8,8 @@ var es = require('event-stream'); | ||
if (typeof options === 'undefined') { | ||
options = {}; | ||
}; | ||
options.start_comment = (typeof options.start_comment === 'undefined') ? 'test-code' : options.start_comment; | ||
options.end_comment = (typeof options.end_comment === 'undefined') ? 'end-test-code' : options.end_comment; | ||
options.keep_comments = typeof options.keep_comments !== 'undefined'; | ||
options.keep_comments = typeof options.keep_comments === 'undefined' ? false : options.keep_comments; | ||
@@ -13,0 +16,0 @@ var pattern = options.pattern || new RegExp("([\\t ]*\\/\\* ?" + options.start_comment + " ?\\*\\/)[\\s\\S]*?(\\/\\* ?" + options.end_comment + " ?\\*\\/[\\t ]*\\n?)", "g"); |
{ | ||
"name": "gulp-strip-code", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "A gulp plugin to remove parts of code based on regular expressions.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -95,2 +95,3 @@ gulp-strip-code | ||
* 0.1.4 small bugs fixed | ||
* 0.1.3 keep comments option added | ||
@@ -97,0 +98,0 @@ * 0.1.2 default values added |
@@ -20,2 +20,19 @@ var stripCode = require('../'); | ||
describe('stripCode()', function() { | ||
it('should remove code from start_comment to end_comment on a buffer with default options', function(done) { | ||
var file = new gutil.File({ | ||
path: 'test/fixtures/original-default.js', | ||
cwd: 'test/', | ||
base: 'test/fixtures', | ||
contents: fs.readFileSync('test/fixtures/original-default.js') | ||
}); | ||
var stream = stripCode(); | ||
stream.on('data', function(newFile) { | ||
should.exist(newFile); | ||
should.exist(newFile.contents); | ||
String(newFile.contents).should.equal(fs.readFileSync('test/expected/modified-default.js', 'utf8')); | ||
done(); | ||
}); | ||
stream.write(file); | ||
stream.end(); | ||
}); | ||
it('should remove pattern', function(done) { | ||
@@ -60,3 +77,3 @@ var file = new gutil.File({ | ||
}); | ||
it('should remove code from start_comment to end_comment on a buffer but keep comments', function(done) { | ||
it('should remove code from start_comment to end_comment but keep comments with the option specified and true', function(done) { | ||
var file = new gutil.File({ | ||
@@ -82,2 +99,43 @@ path: 'test/fixtures/originalkeepcomments.css', | ||
}); | ||
it('should remove code from start_comment to end_comment without keeping comments with the option specified and false', function(done) { | ||
var file = new gutil.File({ | ||
path: 'test/fixtures/originalkeepcomments.css', | ||
cwd: 'test/', | ||
base: 'test/fixtures', | ||
contents: fs.readFileSync('test/fixtures/originalkeepcomments.css') | ||
}); | ||
var stream = stripCode({ | ||
start_comment: "keepcomments", | ||
end_comment: "end-keepcomments", | ||
keep_comments: false | ||
}); | ||
stream.on('data', function(newFile) { | ||
should.exist(newFile); | ||
should.exist(newFile.contents); | ||
String(newFile.contents).should.equal(''); | ||
done(); | ||
}); | ||
stream.write(file); | ||
stream.end(); | ||
}); | ||
it('should remove code from start_comment to end_comment without keeping comments with the option not specified', function(done) { | ||
var file = new gutil.File({ | ||
path: 'test/fixtures/originalkeepcomments.css', | ||
cwd: 'test/', | ||
base: 'test/fixtures', | ||
contents: fs.readFileSync('test/fixtures/originalkeepcomments.css') | ||
}); | ||
var stream = stripCode({ | ||
start_comment: "keepcomments", | ||
end_comment: "end-keepcomments" | ||
}); | ||
stream.on('data', function(newFile) { | ||
should.exist(newFile); | ||
should.exist(newFile.contents); | ||
String(newFile.contents).should.equal(''); | ||
done(); | ||
}); | ||
stream.write(file); | ||
stream.end(); | ||
}); | ||
it('should error on a stream', function(done) { | ||
@@ -84,0 +142,0 @@ var file = new gutil.File({ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12893
14
221
103