Navigation Menu

Skip to content

Commit

Permalink
bring caching back
Browse files Browse the repository at this point in the history
  • Loading branch information
zeke committed Sep 10, 2013
1 parent b8a6635 commit ef57f21
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
35 changes: 17 additions & 18 deletions bin/compile
Expand Up @@ -62,31 +62,30 @@ cache_store_dir="$cache_dir/node_modules/$node_version"
cache_target_dir="$build_dir/node_modules"

# Restore node_modules from cache, if present
# if [ -d $cache_store_dir ]; then
# status "Restoring node_modules cache"
# if [ -d $cache_target_dir ]; then
# cp -r $cache_store_dir/* $cache_target_dir/
# else
# cp -r $cache_store_dir $cache_target_dir
# fi
# status "Pruning any unused dependencies"
# npm prune
# fi

cd $build_dir
if [ -d $cache_store_dir ]; then
status "Restoring node_modules cache"
if [ -d $cache_target_dir ]; then
cp -r $cache_store_dir/* $cache_target_dir/
else
cp -r $cache_store_dir $cache_target_dir
fi
status "Pruning any unused dependencies"
npm prune
fi

# Install dependencies
status "Installing dependencies"
cd $build_dir
npm install --production
npm rebuild

# Cache node_modules for future builds
# if [ -d $cache_target_dir ]; then
# status "Caching node_modules for future builds"
# rm -rf $cache_store_dir
# mkdir -p $(dirname $cache_store_dir)
# cp -r $cache_target_dir $cache_store_dir
# fi
if [ -d $cache_target_dir ]; then
status "Caching node_modules for future builds"
rm -rf $cache_store_dir
mkdir -p $(dirname $cache_store_dir)
cp -r $cache_target_dir $cache_store_dir
fi

# Update the PATH
status "Building runtime environment"
Expand Down
10 changes: 5 additions & 5 deletions bin/test
Expand Up @@ -51,11 +51,11 @@ testProfileCreated() {
assertCapturedSuccess
}

# testNodeModulesCached() {
# cache=$(mktmpdir)
# compile "node-modules-caching" $cache
# assertEquals "1" "$(ls -1 $cache/node_modules/0.10.17 | wc -l)"
# }
testNodeModulesCached() {
cache=$(mktmpdir)
compile "node-modules-caching" $cache
assertEquals "1" "$(ls -1 $cache/node_modules/0.10.18 | wc -l)"
}

## utils ########################################

Expand Down
3 changes: 1 addition & 2 deletions test/node-modules-caching/package.json
Expand Up @@ -7,8 +7,7 @@
"url" : "http://github.com/example/example.git"
},
"engines": {
"node": "0.10.15",
"npm": "1.3.5"
"node": "0.10.18"
},
"dependencies": {
"express": "latest"
Expand Down

0 comments on commit ef57f21

Please sign in to comment.