gulp-strip-debug-option
Version:
Strip console and debugger statements from JavaScript code
28 lines (23 loc) • 638 B
JavaScript
;
const through = require('through2');
const stripDebug = require('strip-debug-option');
const PluginError = require('plugin-error');
module.exports = (option) => {
return through.obj(function (file, enc, cb) {
if (file.isNull()) {
cb(null, file);
return;
}
if (file.isStream()) {
cb(new PluginError('gulp-strip-debug', 'Streaming not supported'));
return;
}
try {
file.contents = Buffer.from(stripDebug(file.contents.toString(),option).toString());
this.push(file);
} catch (err) {
this.emit('error', new PluginError('gulp-strip-debug', err, {fileName: file.path}));
}
cb();
});
};