Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
gulp-remove-code
Advanced tools
A Gulp plugin to remove sections of code from files based on conditions
npm install gulp-remove-code --save-dev
const removeCode = require('gulp-remove-code');
gulp.src('./src/*.js')
.pipe(removeCode({ noDevFeatures: true }))
.pipe(gulp.dest('./dist/'))
gulp.src('./src/*.js')
.pipe(removeCode({ noDevFeatures: true, commentStart: '/*', commentEnd: '*/' }))
.pipe(gulp.dest('./dist/'))
gulp.src('./src/*.coffee')
.pipe(removeCode({ noDevFeatures: true }))
.pipe(gulp.dest('./dist/'))
<div>
<!--removeIf(production)-->
<div class="sandbox-banner">Running in sandbox environment</div>
<!--endRemoveIf(production)-->
<span>Removing code is easy.</span>
</div>
const removeCode = require('gulp-remove-code');
gulp.src('./src/file.html')
.pipe(removeCode({ production: true }))
.pipe(gulp.dest('./dist'))
The plugin will remove the code inside the comments, as well as the comments.
let value = JSON.stringify({key: 'value'});
//removeIf(production)
value = JSON.stringify({key: 'value', production: true}, null, 2);
//endRemoveIf(production)
//removeIf(!development)
value = JSON.stringify({key: 'value', development: false}, null, 2);
//endRemoveIf(!development)
const removeCode = require('gulp-remove-code');
gulp.src('./src/file.js')
.pipe(removeCode({ production: true }))
.pipe(gulp.dest('./dist'))
The plugin will remove the code inside the comments, as well as the comments.
Starting with version 2 of this plugin, conditions can also be expressed using the !
specifier.
// Remove code using *!* (negated) conditions
//----------- gulpfile.js -----------
//
const removeCode = require('gulp-remove-code');
gulp.src('./src/file.js')
.pipe(removeCode({ production: false }))
.pipe(gulp.dest('./dist'))
//----------- app-file.js -----------
//
//removeIf(!production)
value = JSON.stringify({key: 'value', production: false}, null, 2);
//endRemoveIf(!production)
Type: Object
A key value pair map to specify what code should be removed. The truthy values will remove the code.
Type: String
Default: Detected from file extension. Use // as fallback.
Configure how the start comment is defined.
Type: String
Default: Detected from file extension. Use empty as fallback.
Configure how the end comment is defined.
MIT © Cristian Trifan
FAQs
Remove sections of code from files based on conditions
The npm package gulp-remove-code receives a total of 5,087 weekly downloads. As such, gulp-remove-code popularity was classified as popular.
We found that gulp-remove-code demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.