Unverified Commit 1bc7e183 authored by Jeremy Morrell's avatar Jeremy Morrell Committed by GitHub

Fix yarn run error when script is empty string (#624)

* Fix yarn run error when script is empty string
parent 9d563898
...@@ -21,13 +21,18 @@ run_if_present() { ...@@ -21,13 +21,18 @@ run_if_present() {
local build_dir=${1:-} local build_dir=${1:-}
local script_name=${2:-} local script_name=${2:-}
local has_script_name local has_script_name
local script
has_script_name=$(has_script "$build_dir/package.json" "$script_name") has_script_name=$(has_script "$build_dir/package.json" "$script_name")
script=$(read_json "$build_dir/package.json" ".scripts[\"$script_name\"]")
if [[ "$has_script_name" == "true" ]]; then if [[ "$has_script_name" == "true" ]]; then
if $YARN; then if $YARN; then
echo "Running $script_name (yarn)" echo "Running $script_name (yarn)"
# yarn will throw an error if the script is an empty string, so check for this case
if [[ -n "$script" ]]; then
monitor "$script_name" yarn run "$script_name" monitor "$script_name" yarn run "$script_name"
fi
else else
echo "Running $script_name" echo "Running $script_name"
monitor "$script_name" npm run "$script_name" --if-present monitor "$script_name" npm run "$script_name" --if-present
......
A fake README, to keep npm from polluting stderr.
\ No newline at end of file
{
"name": "node-buildpack-test-app",
"version": "0.0.1",
"description": "node buildpack integration test app",
"repository" : {
"type" : "git",
"url" : "http://github.com/example/example.git"
},
"scripts" : {
"build" : "echo build hook message",
"heroku-postbuild": ""
},
"heroku-run-build-script": true
}
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
...@@ -87,6 +87,14 @@ testPreferEmptyHerokuPostbuildOverBuild() { ...@@ -87,6 +87,14 @@ testPreferEmptyHerokuPostbuildOverBuild() {
assertCapturedSuccess assertCapturedSuccess
} }
testEmptyHerokuPostbuildWithYarn() {
compile "empty-heroku-postbuild-yarn"
assertCaptured "Running heroku-postbuild (yarn)"
assertNotCaptured "build hook message"
assertNotCaptured "Script must exist"
assertCapturedSuccess
}
testPrePostBuildScripts() { testPrePostBuildScripts() {
compile "pre-post-build-scripts" compile "pre-post-build-scripts"
assertCaptured "Running heroku-prebuild" assertCaptured "Running heroku-prebuild"
......
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