Skip to content

Commit 371c8b8

Browse files
committed
chore(travis): add npm/install-dependencies.sh step in preparation for caching
1 parent eb87f5f commit 371c8b8

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,22 @@ before_install:
2828
- ./scripts/ci/install_dart.sh ${DART_CHANNEL} ${ARCH}
2929
- sh -e /etc/init.d/xvfb start
3030
- if [[ -e SKIP_TRAVIS_TESTS ]]; then { cat SKIP_TRAVIS_TESTS ; exit 0; } fi
31+
32+
install:
33+
# Check the size of caches
34+
- du -sh ./node_modules || true
35+
# Install npm dependecies and ensure that npm cache is not stale
36+
- tools/npm/install-dependencies.sh
37+
3138
before_script:
3239
- mkdir -p $LOGS_DIR
40+
3341
script:
3442
- ./scripts/ci/build_and_test.sh ${MODE}
43+
3544
after_script:
3645
- ./scripts/ci/print-logs.sh
46+
3747
notifications:
3848
webhooks:
3949
urls:

tools/npm/install-dependencies.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
SHRINKWRAP_FILE=npm-shrinkwrap.json
6+
SHRINKWRAP_CACHED_FILE=node_modules/npm-shrinkwrap.cached.json
7+
8+
if diff -q $SHRINKWRAP_FILE $SHRINKWRAP_CACHED_FILE; then
9+
echo 'No shrinkwrap changes detected. npm install will be skipped...';
10+
else
11+
echo 'Blowing away node_modules and reinstalling npm dependencies...'
12+
rm -rf node_modules
13+
npm install
14+
cp $SHRINKWRAP_FILE $SHRINKWRAP_CACHED_FILE
15+
echo 'npm install successful!'
16+
fi

0 commit comments

Comments
 (0)