You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add option to remove just comments if the value being checked is false #11
I'm trying to use this module to set up an "init" task that will take some general source files and remove any modules that I don't need for a given project. So far I think I've got a good idea of how this can work, but I'm running in to a small issue.
When passing false as the value for the condition your checking, it'd be nice if there was an additional option removeCommentsIfFalse (or something like that) that would remove just the comments and leave the code within as-is.
I can probably work around this using additional modules and regular expressions, but I think this would a be great feature to bake-in.
I've accomplished this use a regular expression with gulp-replace. It's not ideal, but it'll do. Here's the task:
// remove any remaining comments
gulp.src(global.settings.paths.src + "/**/*")
// check if a file is a binary
.pipe(plugins.is_binary())
// skip file if it's a binary
.pipe(plugins.through.obj(function (file, enc, next) {
if (file.isBinary()) {
next();
return;
}
// go to next file
next(null, file);
}))
.pipe(plugins.replace(/((?:\/\*|<!--)(?:end)?[rR]emoveIf\([^)]+\)(?:\*\/|-->))/g, ""))
.pipe(gulp.dest(global.settings.paths.src));
Activity
JacobDB commentedon Jun 8, 2017
I've accomplished this use a regular expression with gulp-replace. It's not ideal, but it'll do. Here's the task:
crissdev commentedon Jun 11, 2017
Duplicate of #3