-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·31 lines (23 loc) · 1.03 KB
/
build.sh
File metadata and controls
executable file
·31 lines (23 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash
# For now we do not do anything within the build process other than make a copy of the source
# and put it in a root dist/ directory
# pwd should be the root of the workspace
if [ ! -f ./lerna.json ]; then
echo "Error: This script must be run from the root of the workspace"
exit 1
fi
workspaceRoot=$(pwd)
# Teardown any old outputs
rm -rf ./dist
# Build any packages which require a build step
npx nx run-many -t build
# Rerun install step to ensure lerna dist is linked appropriately
npm install
# Resolve the packages using lerna itself
IFS=$'\n' read -d '' -a packageLocations < <((node -e 'const fs = require("fs"); const pkgs = JSON.parse(fs.readFileSync(0, "utf-8")); for (const p of pkgs) { console.log(p.location); }') <<<"$(npx lerna list --json)")
for packageLocation in "${packageLocations[@]}"; do
newLocation=$(echo "./dist/${packageLocation#${workspaceRoot}/}/")
mkdir -p $newLocation
cp -R $packageLocation/. $newLocation/.
done
echo "Successfully copied all ${#packageLocations[@]} packages to ./dist"