LoginSignup
1
0

More than 3 years have passed since last update.

npmコマンドの直列処理、並列処理の簡単な記述

Last updated at Posted at 2020-02-26

npmコマンドを簡単に記述して、直列処理、並列処理を行います。

前提条件

  • npmがインストールされていること
  • package.jsonがあること

インストール

$ npm install -D npm-run-all

使い方

設定

run-sの後にコマンドを書くと直列、run-pの後にコマンドを書くと並列で処理を行ってくれます。
コマンドをhello:*と書くと、当てはまるすべてのコマンドを処理します。

package.json
{
  "scripts": {
    "hello:foo": "echo FOO",
    "hello:bar": "echo BAR",
    "hello-s": "run-s hello:foo hello:bar",
    "hello-p": "run-p hello:*"
  }
}

実行

npmコマンドでhello-sまたはhello-pを実行します。

$ npm run hello-s
$ npm run hello-p

出力結果

FOO
BAR

参考文献

この記事は以下の情報を参考にして執筆しました。

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