forked from versatica/JsSIP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
npm-scripts.js
66 lines (52 loc) · 1.17 KB
/
npm-scripts.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const process = require('process');
const { execSync } = require('child_process');
const { version } = require('./package.json');
const task = process.argv.slice(2).join(' ');
// eslint-disable-next-line no-console
console.log(`npm-scripts.js [INFO] running task "${task}"`);
switch (task)
{
case 'lint':
{
execute('gulp lint');
break;
}
case 'test':
{
execute('gulp test');
break;
}
case 'prepublish':
{
execute('gulp babel');
break;
}
case 'release':
{
execute('gulp');
execute(`git commit -am '${version}'`);
execute(`git tag -a ${version} -m '${version}'`);
execute('git push origin master && git push origin --tags');
execute('npm publish');
// eslint-disable-next-line no-console
console.log('update tryit-jssip and JsSIP website');
break;
}
default:
{
throw new TypeError(`unknown task "${task}"`);
}
}
function execute(command)
{
// eslint-disable-next-line no-console
console.log(`npm-scripts.js [INFO] executing command: ${command}`);
try
{
execSync(command, { stdio: [ 'ignore', process.stdout, process.stderr ] });
}
catch (error)
{
process.exit(1);
}
}