feat: Added script for publishing pattern workbenches
This commit is contained in:
parent
9175ab3553
commit
6582d7da2f
1 changed files with 26 additions and 0 deletions
26
scripts/workbenches.js
Normal file
26
scripts/workbenches.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
const patterns = require('@freesewing/pattern-info').list
|
||||||
|
const path = require('path')
|
||||||
|
const spawn = require('child_process').spawn
|
||||||
|
|
||||||
|
const dir = path.join(__dirname, '..')
|
||||||
|
|
||||||
|
const buildPatternWorkbenches = (patterns) => {
|
||||||
|
promises = []
|
||||||
|
for (pattern of patterns) {
|
||||||
|
let cwd = path.join(dir, 'packages', pattern, 'example')
|
||||||
|
promises.push(runScript(cwd, 'npm run build'))
|
||||||
|
promises.push(runScript(cwd, 'netlify deploy --prod'))
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.all(promises)
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
Loading…
Add table
Add a link
Reference in a new issue