From d213f9803226946a10709e91be94b7245181bcd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Thu, 21 Jun 2018 16:00:30 +0200 Subject: [PATCH] Make execution of `pack.sh` much faster Since the `pack.sh` script is supposed to be run after `build.sh` was executed, the `prepare` script of all packages was already performed, and it is possible to only run the `prepublish` script, then execute `npm pack --ignore-scripts` in parallel. This removes the double-compilation of all packages (including slow-to-build packages such as `aws-cdk-docs` or `@aws-cdk/resources`, that involve expensive code generation). --- pack.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pack.sh b/pack.sh index f126931e21..20d119d4ed 100755 --- a/pack.sh +++ b/pack.sh @@ -6,5 +6,7 @@ packdir="$PWD/pack" rm -fr ${packdir} mkdir -p ${packdir} -lerna ls | grep -v "private" | cut -d" " -f1 | xargs -n1 -I{} \ - lerna exec --scope {} --stream -- "npm pack && mv *.tgz ${packdir}" +scopes=$(lerna ls 2>/dev/null | grep -v "(private)" | cut -d" " -f1 | xargs -n1 -I{} echo "--scope {}" | tr "\n" " ") +# Run pre-publish script, if any package defines one (we'll run npm-pack assuming stuff was built before) +lerna run ${scopes} --sort --stream prepublish +lerna exec ${scopes} --stream --parallel -- "npm pack --ignore-scripts && mv *.tgz ${packdir}"