Skip to content

Instantly share code, notes, and snippets.

@mofukuma
Created October 14, 2015 03:53
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mofukuma/8f0db9624d7c34824298 to your computer and use it in GitHub Desktop.
Save mofukuma/8f0db9624d7c34824298 to your computer and use it in GitHub Desktop.
WindowsのバッチをNode.jsで書く雛形
//&cls&node %0&pause > nul&exit /b 0
var cp = require('child_process');
var p = console.log;
function $(a){
r = ""+cp.execSync(a);
p("$ "+a+"\n => "+r);
return r;
}
$( "echo test" );
ret = $( "node -v" );
p( "nodejsバージョン:" + ret.match( /[0-9\.]+/ )[0]);
p("\n引数:"+ process.argv);
@standard-software
Copy link

Batファイルとして Node.js の JavaScript ファイルを動かす方法 - Qiita
https://qiita.com/standard-software/items/51ca6f721017a07ca010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment