2020-11-07 12:37:58 +01:00
|
|
|
const patterns = require('@freesewing/pattern-info').list
|
|
|
|
const path = require('path')
|
|
|
|
const spawn = require('child_process').spawn
|
|
|
|
|
|
|
|
const dir = path.join(__dirname, '..')
|
2020-11-07 16:35:39 +01:00
|
|
|
const base = 'aaron'
|
2020-11-07 12:37:58 +01:00
|
|
|
|
2020-11-07 14:24:29 +01:00
|
|
|
const buildPatternWorkbenches = async (patterns) => {
|
2021-01-17 13:31:58 +01:00
|
|
|
for (let pattern of patterns) {
|
2020-11-07 12:37:58 +01:00
|
|
|
let cwd = path.join(dir, 'packages', pattern, 'example')
|
2020-11-07 16:35:39 +01:00
|
|
|
await runScript(cwd, 'rm -rf node_modules yarn.lock')
|
|
|
|
await runScript(cwd, 'yarn install')
|
2020-11-07 14:24:29 +01:00
|
|
|
await runScript(cwd, 'yarn build')
|
|
|
|
await runScript(cwd, 'netlify deploy --prod')
|
2020-11-07 12:37:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const runScript = (cwd, command) =>
|
|
|
|
new Promise((resolve, reject) => {
|
|
|
|
const script = spawn(command, [], { cwd, shell: true })
|
|
|
|
script.stdout.on('data', (data) => process.stdout.write(data))
|
|
|
|
script.on('error', (data) => reject(`Error running ${command} in ${dir}: ${data}`))
|
|
|
|
script.on('exit', () => resolve())
|
|
|
|
}).catch((err) => console.log(err))
|
|
|
|
|
|
|
|
buildPatternWorkbenches(patterns)
|