Skip to content

Commit

Permalink
Make execution of pack.sh much faster
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
RomainMuller committed Jun 21, 2018
1 parent a97c6c6 commit b101d1c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

0 comments on commit b101d1c

Please sign in to comment.