-
Notifications
You must be signed in to change notification settings - Fork 8
npm run scripts
WebModule の package.json には、以下の run-scripts が登録されています。
これらのコマンドは npm run xxx で実行できます。
"scripts": {
"setup": "node ../WebModule/run/setup.js",
"sync": "node ../WebModule/run/sync.js; npm update; node ../WebModule/run/page.js",
"start": "cd ../; Python -m SimpleHTTPServer 8000 &",
"stop": "killall -- Python -m SimpleHTTPServer 8000; exit 0",
"min": "node ../WebModule/run/minify.js --verbose --strict --keep --pretty",
"build": "node ../WebModule/run/minify.js --verbose --strict --keep --module",
"watch": "node ../WebModule/run/watch.js --verbose --run hint",
"page": "node ../WebModule/run/page.js --verbose",
"test": "npm run min; npm run node; npm run browser",
"node": "NODE_ENV=production NODE_PATH=lib node --harmony test/node.js",
"noded": "NODE_ENV=production NODE_PATH=lib node --debug-brk --harmony test/node.js",
"browser": "open http://localhost:8000/Thread.js/test/index.html",
"sim": "node ../WebModule/run/sim.js http://localhost:8000/Thread.js/test/index.html",
"simx": "node ../WebModule/run/sim.js stop",
"hint": "jshint lib/*.js",
"score": "node ../WebModule/run/score.js; open lint/plato/index.html",
"patch": "node ../WebModule/run/patch.js"
}npm run setup コマンドは必要なファイルをコピーするコマンドです。
WebModule を git pull などで更新した後に npm run setup コマンドを実行すると、更新されたファイルを個別に取り込むことができます。
ファイルが既に存在する場合は、 overwrite it? (y/n) が表示されます。 y をタイプすると上書きします。n や enter がタイプされた場合は上書きしません。
- repositoryFullName: Thread.js
- repositoryName: Thread
- copy source dir: /Users/obara.takao/oss/my/WebModule/
- copy target dir: /Users/obara.takao/oss/my/Thread.js/
overwrite: /Users/obara.takao/oss/my/Thread.js/lint/plato/README.md
overwrite: /Users/obara.takao/oss/my/Thread.js/release/README.md
overwrite: /Users/obara.takao/oss/my/Thread.js/test/template/browser.html
overwrite: /Users/obara.takao/oss/my/Thread.js/test/template/node.js
overwrite: /Users/obara.takao/oss/my/Thread.js/test/template/nw.html
overwrite: /Users/obara.takao/oss/my/Thread.js/test/template/nw.package.json
overwrite: /Users/obara.takao/oss/my/Thread.js/test/template/worker.js
overwrite: /Users/obara.takao/oss/my/Thread.js/.gitignore
overwrite: /Users/obara.takao/oss/my/Thread.js/.jshintrc
overwrite: /Users/obara.takao/oss/my/Thread.js/.npmignore
overwrite: /Users/obara.takao/oss/my/Thread.js/.travis.yml
overwrite: /Users/obara.takao/oss/my/Thread.js/index.js
exists: /Users/obara.takao/oss/my/Thread.js/lib/Thread.js - overwrite it? (y/n):
skip: /Users/obara.takao/oss/my/Thread.js/lib/Thread.js
exists: /Users/obara.takao/oss/my/Thread.js/test/testcase.js - overwrite it? (y/n):
skip: /Users/obara.takao/oss/my/Thread.js/test/testcase.js
exists: /Users/obara.takao/oss/my/Thread.js/package.json - overwrite it? (y/n):
skip: /Users/obara.takao/oss/my/Thread.js/package.json
exists: /Users/obara.takao/oss/my/Thread.js/README.md - overwrite it? (y/n):
skip: /Users/obara.takao/oss/my/Thread.js/README.md
done.
Available next actions,
`$ npm run` # list up npm run-script
`$ npm start` # start local httpd server
`$ npm run sync` # sync scripts, install/update node modules, create test pages and minifynpm run sync コマンドは package.json のフォーマットチェックを行い、自動アップグレードを行います。
また、 npm update と npm run page コマンドを実行し、
依存モジュールの自動更新と、テストに必要なファイル(test/*.html や test/*.js)の再作成を行います。
npm run start や npm start コマンドは 簡易httpサーバを起動します。ポートは 8000 です。
http://localhost:8000/モジュール名.js/test/index.html でモジュールのテストページにアクセスできます。
npm run stop や npm stop コマンドは npm run start コマンドで起動した簡易httpサーバを終了します。
npm run min コマンドはデバッグ用のビルドを行います。 lib/*.js をビルドし、release/*.min.js を生成します。
生成する *.min.js には node_modules 以下の依存モジュールのコードは同梱されていません。
npm run build コマンドはリリース用のビルドを行います。 lib/*.js と依存関係にある node_modules 以下の lib/*.js を取り込んだ形でビルドを行います。
npm run watch コマンドは、lib/*.js に対する変更を監視し、 --run で指定されたコマンドを実行します。
変化で npm run hint コマンドを実行します。
"watch": "node ../WebModule/run/watch.js --verbose --run hint",
変化で npm run min コマンドを実行します。
"watch": "node ../WebModule/run/watch.js --verbose --run min",
変化で 任意のコマンドを実行します。
"watch": "node ../WebModule/run/watch.js --verbose --command xxx",
(xxx の引数は指定できません)
npm run page コマンドは test/template/* ファイルを元に test/*.html や test/*.js ファイルを生成します。
npm run test コマンドは npm run min npm run node npm run browser コマンドを実行します。
npm run node コマンドは node.js 上で test/node.js のテストを実行します。
npm run noded コマンドは test/node.js を使ったテストを --debug-brk オブション付きで実行します。
このコマンドを使うと、node.js で動作するコードを、Chromium の DevTools を使いながら変数のwatchをしたりブレークポイントで止めながらデバッグできます。
詳しくはこちらのエントリを参照してください。
npm run browser コマンドは ブラウザを起動し test/index.html と test/worker.js のテストを実行します。
npm run sim コマンドは iOS Simulator を起動し test/index.html と test/worker.js のテストを実行します。
npm run simx コマンドは npm run sim コマンドにより起動している iOS Simulator のインスタンスを終了します。
npm run hint コマンドは jshint lib/*.js を実行し結果を画面に表示します。
npm run score コマンドはカバレッジツール(plato)を実行し、lib/*.js の静的解析を行った結果を点数化しブラウザに表示します。
npm run patch コマンドは package.json の version プロパティの末尾の番号を +1 します。
> node ../WebModule/run/patch.js
update patch version. 0.0.10 -> 0.0.11