Skip to content

Instantly share code, notes, and snippets.

@tilap
Last active December 1, 2015 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tilap/281275e6bb0930f701ba to your computer and use it in GitHub Desktop.
Save tilap/281275e6bb0930f701ba to your computer and use it in GitHub Desktop.
Gulp: replace {BACK}...{/BACK} by nothing
/**
* Put some code section in command before moving them
*
* @example
* ```
* let start = 1;
* // {BACK}
* let backendvar = 'red is dead';
* // {/BACK}
* let end = 1;
* ```
* will output
* ```
* let start = 1;
* // // {BACK}
* // let backendvar = 'red is dead';
* // // {/BACK}
* let end = 1;
* ```
*/
import gulp from 'gulp';
import replace from 'gulp-replace';
return gulp.src('./src/*.js')
.pipe($.replace(/\/\/\s*\{BACK\}(.|[\n])*BACK\}/ig, function(reg) {
return reg.split('\n').join('\n// ');
}))
.pipe(gulp.dest('./dist'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment