Skip to content

Commit d116cd8

Browse files
committed
Get globalconfig from env
1 parent 5259fde commit d116cd8

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

lib/install.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22
const npmrc = require('./npmrc');
3-
const exec = require('mz/child_process').exec;
43

54
var argv;
65
try {
@@ -9,19 +8,12 @@ try {
98
argv = process.argv;
109
}
1110

12-
// 查找npmrc文件路径
13-
exec('npm config get globalconfig').then(result => {
14-
var configFile = result[0] && result[0].trim();
15-
if (!configFile) {
16-
throw result[1];
11+
npmrc(argv, process.env.npm_config_globalconfig).catch(e => {
12+
if (e.code === 'EACCES' || /\bpermissions?\b/i.test(e.message)) {
13+
console.error(e.message);
14+
console.error('Please try running this command again as root/Administrator.');
15+
} else {
16+
console.error(e);
1717
}
18-
return npmrc(argv, configFile).catch(e => {
19-
if (e.code === 'EACCES' || /\bpermissions?\b/i.test(e.message)) {
20-
console.error(e.message);
21-
console.error('Please try running this command again as root/Administrator.');
22-
} else {
23-
console.error(e);
24-
}
25-
process.exitCode = 1;
26-
});
18+
process.exitCode = 1;
2719
});

0 commit comments

Comments
 (0)