Tools:an IED tool with auto-compilationCreate a file, the file name is arbitrary, can be modifiedTest.cmd
65001%~dp0test_cmd.js>/f/s//f/s/q test_cmd.min.js
View Code
Test_cmd.jsInstall node on premise.
varFS = require ("FS");varFileType = "html";//compiled file type (file suffix) before compilingvarFiletypeto = "html";//compiled file type (file suffix) after compilation//File WritefunctionXieru (fileName) {if(!fileName) { return false; } //to create a readable stream varReaderstream = Fs.createreadstream (filename+ '. ') +FileType); varWriterstream = Fs.createwritestream (filename+ '. Min. ' +Filetypeto);//set the encoding to UTF8. Readerstream.setencoding (' UTF8 ');//Process Stream Events--data, end, and errorReaderstream.on (' Data ',function(chunk) {vardata =Chunk; Data= Data.replace (/^aa/img, "Zhang Yunshan"); Writerstream.write (data,' UTF8 '); Writerstream.end (); //Process Stream Events--data, end, and errorWriterstream.on (' Finish ',function() {Console.log ("Write complete. "); }); Writerstream.on (' Error ',function(Err) {console.log (err.stack); }); }); Readerstream.on (' End ',function() {Console.log ("Read Complete"); }); Readerstream.on (' Error ',function(Err) {console.log (err.stack); }); Console.log ("Program execution Complete");}///Get the file of the current directoryFs.readdir ("./",function(err, files) {if(err) {returnConsole.error (ERR); } Files.foreach (function(file) {if(File.indexof ("." +filetype)! =-1 && file.indexof ("Min.") +filetype) = =-1){ varFileName = File.replace (NewREGEXP ("\.") +filetype+ "$", "IMG"), ""); Xieru (FileName); } });});View Code
Use:
Customizable to compile your own language, or frame
cmd batch, webstrom/phpstrom/..... IDE Tools compile