-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuildRelease.js
48 lines (40 loc) · 1.16 KB
/
buildRelease.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const { error, log, info } = require('../utils/log')
const inquirer = require('inquirer')
const execa = require('execa')
const tar = require('tar')
const choices = ['No build step', 'composer install', 'gulp build']
module.exports = async ({ pluginName: fileName }) => {
const { buildCommand } = await inquirer.prompt([
{
type: 'list',
name: 'buildCommand',
message:
'What build command do you want to run before pushing the release?',
choices
}
])
if (buildCommand !== choices[0]) {
try {
info(`Running the command: ${buildCommand}`)
const [command, ...restArgs] = buildCommand.split(' ')
console.log(command, restArgs)
const { stderrr } = await execa(command, restArgs)
error(stderrr)
} catch (err) {
error(err)
// ToDo: make running build more sophisticated
log('ignoring the build error')
}
}
log(`Creating tar file..`)
const { stdout: tempFileName } = await execa('mktemp', `${fileName}XXXXXXXX`)
const result = await tar.c(
{
gzip: true,
file: tempFileName
},
['./']
)
log(`Tar file created. ${tempFileName}`)
return tempFileName
}