2014-08-01 10:46:08 +08:00
#!/bin/sh
die () { echo "$@" ; exit 1; }
2016-11-04 13:15:18 +08:00
\. ../../../nvm.sh
2014-08-01 10:46:08 +08:00
2018-02-09 14:53:41 +08:00
nvm exec 0.10.28 npm install -g npm@~1.4.11 && nvm install-latest-npm # this is required because before 1.4.10, npm ls doesn't indicated linked packages
nvm exec 0.10.29 npm install -g npm@~1.4.11 && nvm install-latest-npm # this is required because before 1.4.10, npm ls doesn't indicated linked packages
2015-06-29 15:04:59 +08:00
2014-08-01 10:46:08 +08:00
nvm use 0.10.28
2015-03-17 14:46:41 +08:00
(cd test-npmlink && npm link)
2014-08-01 10:46:08 +08:00
2019-12-10 00:51:46 +08:00
EXPECTED_PACKAGES="autoprefixer bower david grunt-cli grunth-cli http-server jshint marked node-gyp npmlist recursive-blame spawn-sync test-npmlink uglify-js yo"
EXPECTED_PACKAGES_INSTALL="autoprefixer bower david@11 grunt-cli grunth-cli http-server jshint marked node-gyp npmlist recursive-blame spawn-sync test-npmlink uglify-js yo@1"
2014-08-01 10:46:08 +08:00
2019-12-10 00:51:46 +08:00
echo "$EXPECTED_PACKAGES_INSTALL" | sed -e 's/test-npmlink //' | xargs npm install -g --quiet
2014-08-01 10:46:08 +08:00
2015-03-15 06:08:14 +08:00
get_packages() {
npm list -g --depth=0 | \sed -e '1 d' -e 's/^.* \(.*\)@.*/\1/' -e '/^npm$/ d' | xargs
}
2014-08-01 10:46:08 +08:00
nvm use 0.10.29
2015-03-15 06:08:14 +08:00
ORIGINAL_PACKAGES=$(get_packages)
2014-08-01 10:46:08 +08:00
2014-11-23 02:52:44 +08:00
nvm reinstall-packages 0.10.28
2015-03-15 06:08:14 +08:00
FINAL_PACKAGES=$(get_packages)
2014-08-01 10:46:08 +08:00
2019-12-10 00:51:46 +08:00
[ "$FINAL_PACKAGES" = "$EXPECTED_PACKAGES" ] || die "final packages ($FINAL_PACKAGES) did not match expected packages ($EXPECTED_PACKAGES)"
2014-08-01 10:46:08 +08:00
[ "$ORIGINAL_PACKAGES" != "$FINAL_PACKAGES" ] || die "original packages matched final packages ($ORIGINAL_PACKAGES)"
2015-03-17 14:46:41 +08:00
[ $(test-npmlink) = 'ok' ] || die "failed to run test-npmlink"