-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathyarn_install.yml
More file actions
37 lines (35 loc) · 1.54 KB
/
yarn_install.yml
File metadata and controls
37 lines (35 loc) · 1.54 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
32
33
34
35
36
37
description: Install Javascript dependencies using Yarn. This command correctly configures the cache for any number of package.json and yarn.lock files.
parameters:
cache:
description: Save and restore the build cache? Defaults to true
type: boolean
default: true
cache_folder:
description: The path to the yarn cache folder. Defaults to /tmp/yarn
type: string
default: "/tmp/yarn"
steps:
- when:
condition: <<parameters.cache>>
steps:
- run:
name: Create cache checksum file
command: |
mkdir -p ~/.tmp/checksumfiles
find . -type f -name 'package.json' -not -path "*node_modules*" -exec cat {} + >> ~/.tmp/checksumfiles/package.json
find . -type f -name 'yarn.lock' -not -path "*node_modules*" -exec cat {} + >> ~/.tmp/checksumfiles/yarn.lock
- 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 install --frozen-lockfile --non-interactive --cache-folder <<parameters.cache_folder>>"
- when:
condition: <<parameters.cache>>
steps:
- save_cache:
paths:
- <<parameters.cache_folder>>
- node_modules
key: |
yarn-cache-{{ arch }}-{{ checksum "~/.tmp/checksumfiles/package.json" }}-{{ checksum "~/.tmp/checksumfiles/yarn.lock" }}-{{ .Environment.CACHE_VERSION }}