stripper

Strips formatted comments to enable and disable blocks of code, supporting both a simplified syntax and basic preprocessor.

Stripper

Strips formatted comments to enable and disable blocks of code.

$ npm i stripper

This software is meant primarily as a build tool. A basic syntax and simple preprocessor are supported.

var stripper = require('stripper');
var stripped = stripper.strip('lib.js');
// start
do something
// STRIP
strip it
// END_STRIP
// end
// start
do something
// end
var stripper = require('stripper');
var stripped = stripper.strip({path: 'lib.js', inclusive: false, startToken: 'DEBUG', endToken: 'END'});
start
/* DEBUG
debug
END */
end
start
debug
end
var stripper = require('stripper');
var stripped = stripper.strip({path: 'lib.js', preprocess: {FOO: true});
start
// #ifdef FOO
foo
// #else
nofoo
// #endifdef
end
// #ifndef BAR
nobar
// #endifndef
start
foo
nobar
end

See the test folder and code for more usage information.

MIT