LoginSignup
6
4

More than 5 years have passed since last update.

Drone.io で npm install の cache を利かせる

Last updated at Posted at 2015-07-13

こんかなんじになりました。

image: "bradrydzewski/node:0.10"
cache:
  - /tmp/npm
  - /tmp/node_modules
  - /tmp/bower_components
script:
  - pwd
  - whoami
  - mkdir -p /tmp/{npm,node_modules,bower_components}
  - ls -la /tmp/{npm,node_modules,bower_components}
  - sudo chown -R ubuntu:ubuntu /tmp/{npm,node_modules,bower_components}
  - ln -snf /tmp/npm /home/ubuntu/.npm
  - ln -snf /tmp/node_modules node_modules
  - ln -snf /tmp/bower_components app/bower_components
  - time npm install -g coffee karma yo generator-angular grunt-cli bower # -g cannot use cache
  - time npm install
  - time bower install --allow-root --config.interactive=false
  - time grunt test

$(pwd)/node_modules は npm install でモジュールがインストールされるディレクトリで、$HOME/.npm はその時にキャッシュが入るディレクトリ。両方とも、/tmp 以下の cache: で指定したディレクトリに symlink 貼っている。

同様の方法で bower の cache も利かせている。

npm install -g は npm config set prefix でインストール場所を変更することができたが、そもそも -g だと再利用してくれないようで意味がなかった。

6
4
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
6
4