-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy.js
executable file
·51 lines (43 loc) · 1.24 KB
/
deploy.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
const path = require('path');
const spawn = require('cross-spawn');
const pkg = require('./package.json');
function shell(command, directory) {
console.log('$ ' + command);
const args = command.split(' ');
const cmd = args.shift();
const result = spawn.sync(cmd, args, {
cwd: directory || process.cwd(),
env: process.env,
stdio: 'inherit',
encoding: 'utf-8',
});
if (result.status !== 0) {
throw new Error('error with exit code ' + result.status);
}
}
(function () {
const commands = [
// git config
"git config user.name 'Robotism'",
"git config user.email '[email protected]'",
// registry to npmjs
'npm config set registry https://registry.npmjs.org',
// check
'yarn prettier',
'yarn lint-code',
'yarn lint-style',
// build
'yarn build',
// publish
'npm publish --access=public',
// registry to taobao
'npm config set registry https://registry.npm.taobao.org',
];
commands.forEach(function (cmd) {
try {
shell(cmd, path.resolve(process.cwd(), './'));
} catch (err) {
process.exit(result.status);
}
});
})();