Created
October 14, 2015 03:53
-
-
Save mofukuma/8f0db9624d7c34824298 to your computer and use it in GitHub Desktop.
WindowsのバッチをNode.jsで書く雛形
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//&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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Batファイルとして Node.js の JavaScript ファイルを動かす方法 - Qiita
https://qiita.com/standard-software/items/51ca6f721017a07ca010