The batch file code used for packaging is as follows:
Copy codeThe Code is as follows: @ echo off
Title Builder-merging...
Color 03
REM ============================================
REM jsbuilder beta
REM
REM ============================================
SETLOCAL ENABLEEXTENSIONS
Echo.
REM filter file suffix, only combo js files
If "% ~ X1 "NEQ". js "(
Echo.
Echo *** select a JS File
Echo.
Goto End
)
REM check NODE_PATH
If "% NODE_PATH %" = "" goto NoNodePath
If not exist "% NODE_PATH % \ node.exe" goto NoNodePath
Set RESULT_FILE = % ~ N1-combo % ~ X1
: ZIP_CHOICE
Echo: Select whether to [compress] the merged js file?
Set input =
Set/p input =-^> select (y/n ):
If/I "% input %" = "n" goto UNZIP
If/I "% input %" = "y" goto ZIP
REM calls build to merge files
: UNZIP
"% NODE_PATH % \ node.exe" "% ~ Dp0build. js "-- unzip" % ~ N1 % ~ X1 ">" % RESULT_FILE %"
Echo.
Echo ****~ O (distinct _ distinct) O ~ [Merge] successfully ****
Echo.
Goto End
REM calls build to merge and compress files
: ZIP
"% NODE_PATH % \ node.exe" "% ~ Dp0build. js "" % ~ N1 % ~ X1 ">" % RESULT_FILE %"
Echo.
Echo ****~ O (distinct _ distinct) O ~ Merge and compress ****
Echo.
Goto End
: NoNodePath
Echo.
For echo *****, first install NodeJS and set the NODE_PATH environment variable ****
Echo.
: End
ENDLOCAL
Pause
The build. js code for packaging is as follows:
Copy codeThe Code is as follows: // load the configuration
Require ('./config. js ');
// Modules used
Var FS = require ('fs '),
PATH = require ('path '),
Jscombo = require ('./tool/jscombo '),
Util = require ('til ');
// Obtain parameters
Var args = process. argv;
Args = []. slice. call (args, 2 );
Var opts ={}; // Configuration
Var curPath, rootPath = curPath = process. cwd ();
// Set the rootPath according to the relative path of config. js.
If (typeof relativePath! = 'Undefined '){
RootPath = PATH. join (rootPath, relativePath );
}
Var filename; // name of the file to be processed
// Processing Parameters
Out: while (args. length ){
Var v = args. shift ();
Switch (v ){
Case '-uz ':
Case '-- unzip ':
// Compress after combo
Opts. unzip = true;
Break;
Default:
Filename = v;
Break out;
}
}
// Var filePath = PATH. join (rootPath, filename );
// Convert the path of the js file to be compressed to the path of the relative rootpath
Var rPath = PATH. relative (rootPath, PATH. join (curPath, filename ));
Var str = jscombo (rPath, rootPath, opts );
Var fileout = process. stdout;
Fileout. write (str );