-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
453 additions
and
1,574 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,43 @@ | ||
'use strict'; | ||
"use strict"; | ||
|
||
var through = require('through2'); | ||
var decomment = require('decomment'); | ||
var PluginError = require('plugin-error'); | ||
var through = require("through2"); | ||
var decomment = require("decomment"); | ||
var PluginError = require("plugin-error"); | ||
|
||
function main(options, func) { | ||
return through.obj(function (file, enc, cb) { | ||
if (file.isNull()) { | ||
cb(null, file); | ||
return; | ||
} | ||
if (file.isStream()) { | ||
cb(new PluginError("gulp-strip-comments", "Streaming not supported.")); | ||
} | ||
file.contents = new Buffer(func(file.contents.toString(), options)); | ||
this.push(file); | ||
return cb(); | ||
}); | ||
return through.obj(function (file, enc, cb) { | ||
if (file.isNull()) { | ||
cb(null, file); | ||
return; | ||
} | ||
if (file.isStream()) { | ||
cb(new PluginError("gulp-strip-comments", "Streaming not supported.")); | ||
} | ||
try { | ||
file.contents = Buffer.from(func(file.contents.toString(), options)); | ||
this.push(file); | ||
} catch (error) { | ||
this.emit( | ||
"error", | ||
new PluginError("gulp-strip-comments", error, { | ||
fileName: file.path, | ||
}), | ||
); | ||
} | ||
return cb(); | ||
}); | ||
} | ||
|
||
function gulpDecomment(options) { | ||
return main(options, decomment); | ||
return main(options, decomment); | ||
} | ||
|
||
gulpDecomment.text = function (options) { | ||
return main(options, decomment.text); | ||
return main(options, decomment.text); | ||
}; | ||
|
||
gulpDecomment.html = function (options) { | ||
return main(options, decomment.html); | ||
return main(options, decomment.html); | ||
}; | ||
|
||
|
||
module.exports = gulpDecomment; |
Oops, something went wrong.