7
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Node.jsで知ったopenとstartの違い

Last updated at Posted at 2014-07-30

Macはopenコマンドがあって便利だけど

Windowsにだってstartコマンドがあります。

start .

Macの

open .

と同じように使える。便利コマンドです。

Node.jsで違いに気づくことが出来た件

openはそのまま使えるが、startはcmd.exeかまして使う必要がある。
start直だとENOENTのエラーがもれなくついてきた。

var spawn = require('child_process').spawn;
var runstantUrl = "http://phi-jp.github.io/runstant/release/alpha/";
if (process.platform == "darwin") {
  spawn("open", [runstantUrl]);
} else if (process.platform == "win32") {
  spawn("cmd", ["/C","start " +runstantUrl]);
}

まとめ

ターミナルやコマンドプロンプトで使っているだけでは分からないstartとopenの違いがNode.jsでコードを書いてみたら分かりました。

追記

関連記事

7
9
6

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?