-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
24 lines (21 loc) · 846 Bytes
/
index.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
#!/usr/bin/env node
var process = require('child_process');
var npm_registry = 'http://registry.npmjs.org';
// const cnpm_registry = 'https://registry.npm.taobao.org';
var cmd_get_registry = `npm config get registry`;
//直接调用命令
process.exec(cmd_get_registry, function(error, stdout, stderr) {
if (error !== null) {
console.log('[error]' + error);
}else {
var cnpm_registry = stdout.replace(/\s/g, '');
var cmd_publish = `npm config set registry ${npm_registry} && npm publish && npm config set registry ${cnpm_registry} && ${cmd_get_registry}`;
process.exec(cmd_publish, function(error, stdout, stderr) {
if (error !== null) {
console.log('[error]' + error);
}else {
console.log('[success]', stdout);
}
});
}
});