From 5b433a83942cef110deccadb3cecbea03616df02 Mon Sep 17 00:00:00 2001 From: Jeremy Morrell Date: Fri, 2 Mar 2018 14:04:12 -0800 Subject: [PATCH] Skip pruning if NPM_CONFIG_PRODUCTION or YARN_PRODUCTION is defined --- lib/dependencies.sh | 8 ++++---- test/run | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/dependencies.sh b/lib/dependencies.sh index 73520f84..1f4d494e 100644 --- a/lib/dependencies.sh +++ b/lib/dependencies.sh @@ -103,8 +103,8 @@ yarn_prune_devdependencies() { elif [ "$NODE_ENV" != "production" ]; then echo "Skipping because NODE_ENV is not 'production'" return 0 - elif [ -n "$YARN_PRODUCTION" ] && [ "$YARN_PRODUCTION" != "true" ]; then - echo "Skipping because YARN_PRODUCTION is not 'true'" + elif [ -n "$YARN_PRODUCTION" ]; then + echo "Skipping because YARN_PRODUCTION is '$YARN_PRODUCTION'" return 0 else local start=$(nowms) @@ -163,8 +163,8 @@ npm_prune_devdependencies() { elif [ "$NODE_ENV" != "production" ]; then echo "Skipping because NODE_ENV is not 'production'" return 0 - elif [ -n "$NPM_CONFIG_PRODUCTION" ] && [ "$NPM_CONFIG_PRODUCTION" != "true" ]; then - echo "Skipping because NPM_CONFIG_PRODUCTION is not 'true'" + elif [ -n "$NPM_CONFIG_PRODUCTION" ]; then + echo "Skipping because NPM_CONFIG_PRODUCTION is '$NPM_CONFIG_PRODUCTION'" return 0 elif [ "$npm_version" == "5.3.0" ]; then mcount "skip-prune-issue-npm-5.3.0" diff --git a/test/run b/test/run index 65a9390c..064a2da9 100755 --- a/test/run +++ b/test/run @@ -682,7 +682,14 @@ testDevDepenenciesWithNoPruning() { echo "false" > $env_dir/NPM_CONFIG_PRODUCTION compile "dependencies" "$(mktmpdir)" $env_dir assertCaptured "lodash" - assertCaptured "Skipping because NPM_CONFIG_PRODUCTION is not 'true'" + assertCaptured "Skipping because NPM_CONFIG_PRODUCTION is 'false'" + assertCapturedSuccess + + env_dir=$(mktmpdir) + echo "true" > $env_dir/NPM_CONFIG_PRODUCTION + compile "dependencies" "$(mktmpdir)" $env_dir + assertNotCaptured "lodash" + assertCaptured "Skipping because NPM_CONFIG_PRODUCTION is 'true'" assertCapturedSuccess } @@ -692,7 +699,14 @@ testDevDepenenciesWithNoPruningYarn() { echo "false" > $env_dir/YARN_PRODUCTION compile "dependencies-yarn" "$(mktmpdir)" $env_dir assertCaptured "lodash" - assertCaptured "Skipping because YARN_PRODUCTION is not 'true'" + assertCaptured "Skipping because YARN_PRODUCTION is 'false'" + assertCapturedSuccess + + env_dir=$(mktmpdir) + echo "true" > $env_dir/YARN_PRODUCTION + compile "dependencies-yarn" "$(mktmpdir)" $env_dir + assertNotCaptured "lodash" + assertCaptured "Skipping because YARN_PRODUCTION is 'true'" assertCapturedSuccess }