LoginSignup
0
0

More than 5 years have passed since last update.

gulpのお勉強1

Last updated at Posted at 2017-06-24

タスクランナーは消耗するという噂も聞くけど、ちょっとした開発のツールとしてつかう。

非同期タスク

promissとかspawnとか、、サーバーを再起動してからクライアントでapiをたたくてきなタスクを作りたい。

node.jsのchild_processのexecとexecFileとspawnの違い - SundayHacking
http://www.axlight.com/mt/sundayhacking/2014/03/nodejschild-processexecexecfilespawn.html

Run-sequence (Programming) Questions & Answers - TechQA
http://techqa.info/programming/tag/run-sequence

The Complete-Ish Guide to Upgrading to Gulp 4 | Joe Zim's JavaScript Corner
https://www.joezimjs.com/javascript/complete-guide-upgrading-gulp-4/

どうやらexecとかは非同期らしい。。

Child Process | Node.js v8.1.2 Documentation
https://nodejs.org/api/child_process.html

node.js の execSync の戻り値で stderr を受け取る方法 - スタック・オーバーフロー
https://ja.stackoverflow.com/questions/28527/node-js-%E3%81%AE-execsync-%E3%81%AE%E6%88%BB%E3%82%8A%E5%80%A4%E3%81%A7-stderr-%E3%82%92%E5%8F%97%E3%81%91%E5%8F%96%E3%82%8B%E6%96%B9%E6%B3%95

trueコマンドで失敗がないようにするとか、あえてエラーを返すためにfalseしたり、エラーをいれかえて取得したりと。

サーバーが起動してから少しwaitをつけないとダメかも。。

よくわからないがひとまず。。

go = gulpgo.run("./main.go", [], {cwd: __dirname, stdio: 'inherit'});
return ps('sleep 3');

options.stdio

パラメータを渡して、I/Oをパイプしたりできるっぽい。(いまいちわかってない。)
サーバープロセスを立ち上げたら細かい出力がでなかったが、これを設定すると逐次表示されるようになる。

Child Process | Node.js v8.1.3 Documentation
https://nodejs.org/api/child_process.html#child_process_options_stdio

自信ないが、、
pipeだと、実行結果にオブジェクトで返すのかな。
ignoreが破棄で、inheritは逐次出力。
ipcがメッセージングのチャンネルみたいなのを作ってくれる。
オブジェクトを渡すとストリームもできるらしい、、ipcとどう違うの??
整数だとinherit的な出力の入れ替え、nullとかはignoreと同じ。
うーん、オプションを自力で増やして、fd3,fd4をつければ、ipcを使いつつ通常の出力リダイレクトも使える??

0
0
0

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
0
0