forked from kentcdodds/old-kentcdodds.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload-cache.js
33 lines (24 loc) · 784 Bytes
/
load-cache.js
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
const {execSync} = require('child_process')
const path = require('path')
const {ensureDir} = require(`fs-extra`)
async function go() {
if (!process.env.NETLIFY_BUILD_BASE) {
return
}
const netlifyCacheDir = path.resolve(
process.env.NETLIFY_BUILD_BASE,
`cache/gatsby/public/static`,
)
console.log('Loading public/static from netlify cache')
const publicStatic = path.resolve(
process.env.NETLIFY_BUILD_BASE,
`repo/public`,
)
await ensureDir(netlifyCacheDir)
await ensureDir(publicStatic)
execSync(`cp -r "${netlifyCacheDir}" "${publicStatic}"`, {stdio: 'inherit'})
const result = execSync(`find "${publicStatic}" -type f | wc -l`)
console.log(`cache loaded. Total files: ${String(result).trim()}`)
}
go()
/* eslint no-console:0 */