-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (30 loc) · 826 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
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env node
var List = require('term-list');
var exec = require('child_process').exec;
var list = new List({ marker: '> ', markerLength: 2 });
list.add('https://registry.npmjs.org/', 'https://registry.npmjs.org/');
list.add('https://registry.npm.taobao.org/', 'https://registry.npm.taobao.org/');
list.add('https://r.cnpmjs.org/', 'http://r.cnpmjs.org/');
list.add('exit', '[exit]');
list.start();
list.on('keypress', function(key, item){
switch (key.name) {
case 'return':
if (item == 'exit') {
list.stop();
}
else {
exec('npm config set registry "' + item + '"', function(err){
list.stop();
if (err) {
console.log(err);
} else {
}
});
}
break;
}
});
list.on('empty', function(){
list.stop();
});