Last active
December 1, 2015 09:31
-
-
Save tilap/281275e6bb0930f701ba to your computer and use it in GitHub Desktop.
Gulp: replace {BACK}...{/BACK} by nothing
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
/** | |
* 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