Jnclude builds the application file from a several source files and cuts a sections of the code what don't used in application production version. Using flags allow to create application files with different logic or leave special debug code for testing certain algorithm.
- Install node.js
- Run command:
npm install jnclude -g
- For get help of using jnclude run:
jnclude -help
- To run jnclude, you can use the following command:
jnclude -in=path/source.js -out=path/destination.js [options]
-in=/path/src_name
- Main source file name.
-out=/path/dest_name
- Destination file name. If path of destination not specified, file creates in the source folder. But if source path contain file with specified name, jnclude returns error.
-flag="flag_1 [other_flags]"
- Activate including or excluding for blocks marked with flags. If the flags option is given, directives without flag or other flags don't work.
-develop
- If develop option is given all exclude
directives don't work
-fullinfo
- Shows detail information after building:
Jnclude done!
Done: 449.801ms
CPU usage: { user: 15000, system: 0 }
Memory usage:
{ rss: 20500480,
heapTotal: 8421376,
heapUsed: 3805416,
external: 8380 }
Loaded files:
src/core.js - 1 times
src/source.js - 1 times
without -fullinfo
Jnclude done!
Loaded files:
src/core.js - 1 times
src/source.js - 1 times
- include - copy the given file content and put it instead directive with offsets from line begin
//>include(002.js) dev pro
____|_________|______| _______
1 2 3 4
where: 1 - offset, 2 - command, 3 - source file name, 4 - flags
- include_once - checks that this file not used by jnclude earlier and copy the given file content and put it instead directive. If used file earlier directive ignored.
//>include_once(002.js) dev
- exclude - remove code beetween
exclude
and/exclude
if not given-develop
option.
//>exclude pro
alert(error);
//>/exclude
jnclude -in=src/main.js -out=build/result.js
jnclude -in=src/main.js -out=build/result.js -develop -flag="dev_1 dev_2 pro"
jnclude -in=src/main.js -out=build/result.js -flag="pro" -fullinfo
sample/main.js
console.log(1);
//>include(add.js) dev
//>exclude pro
console.log(4);
//>/exclude
//>include_once(add.js) dev pro
sample/add.js
console.log(2);
//>include_once(appendix.js) dev
sample/appendix.js
console.log(3);
run jnclude -in=sample/main.js -out=sample/result.js
sample/result.js
console.log(1);
console.log(2);
console.log(3);
run jnclude -in=sample/main.js -out=sample/result.js -develop
sample/result.js
console.log(1);
console.log(2);
console.log(3);
console.log(4);
run jnclude -in=sample/main.js -out=sample/result.js -flag="dev"
sample/result.js
console.log(1);
console.log(2);
console.log(3);
console.log(4);
run jnclude -in=sample/main.js -out=sample/result.js -flag="pro"
sample/result.js
console.log(1);
console.log(2);
- Excluding debug code
- Including certain block in source files
- Remove comments, console and alert(-noalert) calling
-
-noflag
option - use directives without given flags -
-log
option - generation the comments with directive result description