Skip to content

Commit af4b8ba

Browse files
committed
fix support for node 4
1 parent d4c2d9b commit af4b8ba

File tree

10 files changed

+37
-10
lines changed

10 files changed

+37
-10
lines changed

.eslintrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"extends": [
88
"standard"
99
],
10+
"parserOptions": {
11+
"sourceType": "script",
12+
"ecmaVersion": 2017
13+
},
1014
"root": true,
1115
"rules": {
1216
"prefer-arrow-callback": [

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
language: node_js
22
dist: trusty
33
node_js:
4-
- "stable"
4+
- stable
5+
- 4
56

67
install:
78
- npm install --ignore-scripts
89

910
script:
1011
- nyc npm run install
11-
- "source ~/.bash_profile || source ~/.bashrc || source ~/.zshrc"
1212
- npm test
1313

1414
after_script:

appveyor.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ build: off
66
environment:
77
matrix:
88
- nodejs_version: stable
9+
- nodejs_version: 4
910

1011
# Install scripts. (runs after repo cloning)
1112
install:
1213
# install Node.js
13-
- ps: Install-Product node $env:nodejs_version
14+
- ps: Install-Product node $env:nodejs_version $env:platform
1415
# install modules
1516
- npm install --ignore-scripts
1617

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
'use strict';
22
const config = require('./lib/config')(process.argv);
33
Object.keys(config).forEach(key => {
44
process.env['npm_config_' + key] = config[key];

lib/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env node
2-
2+
'use strict';
33
const npmrc = require('./npmrc');
44
const env = require('./env');
55
const path = require('path');

lib/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
'use strict';
22
function getConf (argv) {
33
const npmrc = {
44
registry: 'http://registry.npm.taobao.org',

lib/env.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
'use strict';
22
const path = require('path');
33
const os = require('os');
44
const exec = (require('util').promisify || require('util.promisify'))(require('child_process').execFile);

lib/install.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
'use strict';
22
const npmrc = require('./npmrc');
33
const env = require('./env');
44

lib/npmrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
'use strict';
22
const fs = require('fs-extra');
33
const config = require('./config');
44

test/index.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
1+
'use strict';
22
const assert = require('assert');
3+
const path = require('path');
4+
const os = require('os');
5+
// const fs = require('fs');
36
const util = require('util');
7+
48
if (!util.promisify) {
59
util.promisify = require('util.promisify');
610
}
11+
712
const exec = util.promisify(require('child_process').execFile);
13+
const readFile = util.promisify(require('fs').readFile);
814

915
describe('environment variables', () => {
1016
before(() => {
@@ -14,6 +20,22 @@ describe('environment variables', () => {
1420
process.env[key] = value;
1521
});
1622
});
23+
} else {
24+
const home = os.homedir();
25+
const files = [
26+
'.bash_profile',
27+
'.bashrc',
28+
'.zshrc'
29+
].map(
30+
file => path.join(home, file)
31+
);
32+
return Promise.all(files.map(file => {
33+
return readFile(file, 'utf8').then(sh => {
34+
sh.replace(/^export\s+(.+?)=("|')?(.+?)\2\s*$/igm, (s, key, quote, value) => {
35+
process.env[key] = value;
36+
});
37+
}, () => {});
38+
}));
1739
}
1840
});
1941

0 commit comments

Comments
 (0)