Repo created
This commit is contained in:
parent
f3a6b3a320
commit
f954c78789
614 changed files with 135712 additions and 2 deletions
32
_scripts/helpers.js
Normal file
32
_scripts/helpers.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
const exec = require('child_process').exec
|
||||
|
||||
/**
|
||||
* Calls `child_process`.exec, but it outputs
|
||||
* all of the stdout live and can be awaited
|
||||
* @param {string} command The command to be executed
|
||||
* @returns
|
||||
*/
|
||||
function execWithLiveOutput (command) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const execCall = exec(command, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(error)
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
execCall.stdout.on('data', (data) => {
|
||||
process.stdout.write(data)
|
||||
})
|
||||
execCall.stderr.on('data', (data) => {
|
||||
console.error(data)
|
||||
})
|
||||
execCall.on('close', () => {
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
execWithLiveOutput
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue