gruntで任意の場所でnpm i --productionする

node-webkitで作成したアプリのパッケージングはappディレクトリを対象として実行してて、npmをcd app してからnpm i --productionと手動で処理していたので、Gruntに登録した。

Gruntfile.coffeeの該当箇所

  ......
    exec:
      npm_i_production:
        cwd: 'app'
        cmd: 'npm i --production'
  .....
  grunt.loadNpmTasks('grunt-exec')
  grunt.registerTask 'default', ['slim', 'concat', 'copy', 'exec','nodewebkit']

OK.

参考