Skip to content

Commit

Permalink
Use conditional logic and use --cwd if not empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdholtz committed Jan 3, 2022
1 parent fb32dab commit b00cb33
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ commands:
yarn_install:
description: Install Javascript dependencies using Yarn. This command correctly configures the cache for any number of package.json and yarn.lock files.
parameters:
yarn_install_directory:
description: Working path. Defaults to "./"
type: string
cache:
description: Save and restore the build cache? Defaults to true
type: boolean
Expand All @@ -21,6 +18,10 @@ commands:
description: The path to the yarn cache folder. Defaults to /tmp/yarn
type: string
default: "/tmp/yarn"
yarn_install_directory:
description: The working directory to run install at. Defaults to yarn's current working directory
type: string
default: ""

steps:
- when:
Expand All @@ -35,9 +36,20 @@ commands:
- restore_cache:
keys:
- yarn-cache-{{ arch }}-{{ checksum "~/.tmp/checksumfiles/package.json" }}-{{ checksum "~/.tmp/checksumfiles/yarn.lock" }}-{{ .Environment.CACHE_VERSION }}
- run:
name: Yarn Install
command: "yarn --cwd <<parameters.yarn_install_directory>> install --frozen-lockfile --non-interactive --cache-folder <<parameters.cache_folder>>"
- when:
condition:
equal: ["", <<parameters.yarn_install_directory>>]
steps:
- run:
name: Yarn Install
command: "yarn install --frozen-lockfile --non-interactive --cache-folder <<parameters.cache_folder>>"
- unless:
condition:
equal: ["", <<parameters.yarn_install_directory>>]
steps:
- run:
name: Yarn Install (<<parameters.yarn_install_directory>>)
command: "yarn --cwd <<parameters.yarn_install_directory>> install --frozen-lockfile --non-interactive --cache-folder <<parameters.cache_folder>>"
- when:
condition: <<parameters.cache>>
steps:
Expand Down Expand Up @@ -79,6 +91,8 @@ jobs:
- yarn_install:
yarn_install_directory: examples/purchaseTesterTypescript
cache_folder: ~/.cache/yarn
- yarn_install:
cache_folder: ~/.cache/yarn
- rn/android_build:
project_path: examples/purchaseTesterTypescript/android
ios:
Expand All @@ -95,6 +109,8 @@ jobs:
- yarn_install:
yarn_install_directory: examples/purchaseTesterTypescript
cache_folder: ~/.cache/yarn
- yarn_install:
cache_folder: ~/.cache/yarn
- rn/pod_install:
pod_install_directory: examples/purchaseTester/ios
- rn/pod_install:
Expand Down

0 comments on commit b00cb33

Please sign in to comment.