Commit 6046385b authored by Hunter Loftis's avatar Hunter Loftis

test and implementation for missing devDependencies

parent 58457e07
......@@ -42,6 +42,7 @@ handle_failure() {
header "Build failed"
warn_untracked_dependencies "$LOG_FILE"
warn_angular_resolution "$LOG_FILE"
warn_missing_devdeps "$LOG_FILE"
failure_message | output "$LOG_FILE"
}
trap 'handle_failure' ERR
......
......@@ -87,3 +87,17 @@ warn_angular_resolution() {
warning "Bower may need a resolution hint for angular" "https://github.com/bower/bower/issues/1746"
fi
}
warn_missing_devdeps() {
local log_file="$1"
if grep -qi 'cannot find module' "$log_file"; then
warning "A module may be missing from package.json" "https://devcenter.heroku.com/articles/troubleshooting-node-deploys#ensure-you-aren-t-relying-on-untracked-dependencies"
if [ "$NPM_CONFIG_PRODUCTION" == "true" ]; then
local devDeps=$(read_json "$BUILD_DIR/package.json" ".devDependencies")
echo "devDependencies: $devDeps"
if [ "$devDeps" != "" ]; then
warning "A module may be specified in devDependencies instead of dependencies" "https://devcenter.heroku.com/articles/nodejs-support#devdependencies"
fi
fi
fi
}
{
"name": "missing-devdeps-1",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"postinstall": "node postinstall.js"
},
"keywords": [],
"author": "",
"license": "ISC"
}
const lodash = require('lodash');
{
"name": "missing-devdeps-1",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"postinstall": "node postinstall.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"lodash": "4.13.1"
}
}
const lodash = require('lodash');
#!/usr/bin/env bash
# See README.md for info on running these tests.
testWarnDevDeps() {
compile "missing-devdeps-1"
assertCaptured "A module may be missing"
assertNotCaptured "A module may be specified"
assertCapturedError
compile "missing-devdeps-2"
assertCaptured "A module may be missing"
assertCaptured "A module may be specified"
assertCapturedError
compile "failing-build"
assertNotCaptured "A module may be missing"
assertNotCaptured "A module may be specified"
assertCapturedError
}
testEnvBlacklist() {
local cache=$(mktmpdir)
local env_dir=$(mktmpdir)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment