From 436694fe7aa1c3e038470d7784f96b0f2fd4f623 Mon Sep 17 00:00:00 2001
From: Jesse Katsumata <niconico.clarinet@gmail.com>
Date: Wed, 29 May 2019 21:07:36 +0900
Subject: [PATCH] chore: allow running buildup and builddown scripts without
 lerna globally installed (#2667)

Modift buildup and builddown script to include `$(npm bin)` in `PATH` so that lerna does not need to be installed globally in order to run the scripts.

Closes #1338
---
 build.sh          | 2 +-
 install.sh        | 2 +-
 scripts/builddown | 1 +
 scripts/buildup   | 1 +
 4 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/build.sh b/build.sh
index 522dff0fe38ba..1cebec875954b 100755
--- a/build.sh
+++ b/build.sh
@@ -43,7 +43,7 @@ fail() {
 BUILD_INDICATOR=".BUILD_COMPLETED"
 rm -rf $BUILD_INDICATOR
 
-export PATH=node_modules/.bin:$PATH
+export PATH=$(npm bin):$PATH
 export NODE_OPTIONS="--max-old-space-size=4096 ${NODE_OPTIONS:-}"
 
 # Speed up build by reusing calculated tree hashes
diff --git a/install.sh b/install.sh
index a8b58bc91a6c1..71d76f6e6e0ea 100755
--- a/install.sh
+++ b/install.sh
@@ -13,7 +13,7 @@ echo "installing repo-global dependencies..."
 npm ci --global-style
 
 # Now that we have lerna available...
-export PATH=node_modules/.bin:$PATH
+export PATH=$(npm bin):$PATH
 
 echo "============================================================================================="
 echo "cleanup and start bootstrapping..."
diff --git a/scripts/builddown b/scripts/builddown
index 870128f91fd8d..e30717bf911d9 100755
--- a/scripts/builddown
+++ b/scripts/builddown
@@ -1,6 +1,7 @@
 #!/bin/bash
 set -euo pipefail
 
+export PATH=$(npm bin):$PATH
 export NODE_OPTIONS="--max-old-space-size=4096 ${NODE_OPTIONS:-}"
 
 scriptdir=$(cd $(dirname $0) && pwd)
diff --git a/scripts/buildup b/scripts/buildup
index 8e2843b3d43ec..26e49ad6b564e 100755
--- a/scripts/buildup
+++ b/scripts/buildup
@@ -1,6 +1,7 @@
 #!/bin/bash
 set -euo pipefail
 
+export PATH=$(npm bin):$PATH
 export NODE_OPTIONS="--max-old-space-size=4096 ${NODE_OPTIONS:-}"
 
 scriptdir=$(cd $(dirname $0) && pwd)