Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Commit

Permalink
chore(ws-cache): don't call yarn workspaces twice
Browse files Browse the repository at this point in the history
  • Loading branch information
JGAntunes committed Feb 26, 2021
1 parent 14b1ea8 commit 073a3db
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions run-build-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ run_yarn() {
if [ "$NETLIFY_YARN_WORKSPACES" = "true" ]
then
echo "NETLIFY_YARN_WORKSPACES feature flag set"
local workspace_output
# YARN_IGNORE_PATH will ignore the presence of a local yarn executable (i.e. yarn 2) and default
# to using the global one (which, for now, is alwasy yarn 1.x). See https://yarnpkg.com/configuration/yarnrc#ignorePath
if YARN_IGNORE_PATH=1 yarn workspaces info
workspace_output=$(YARN_IGNORE_PATH=1 yarn workspaces info)
if $?
then
local package_locations
# Extract all the packages and respective locations. .data will be a JSON object like
Expand All @@ -123,7 +125,7 @@ run_yarn() {
# (...)
# }
# We need to cache all the node_module dirs, or we'll always be installing them on each run
mapfile -t package_locations <<< "$(YARN_IGNORE_PATH=1 yarn --json workspaces info | jq -r '.data | fromjson | to_entries | .[].value.location')"
mapfile -t package_locations <<< "$workspace_output"
restore_js_workspaces_cache "${package_locations[@]}"
else
echo "No workspace detected"
Expand Down

0 comments on commit 073a3db

Please sign in to comment.