Skip to content
This repository was archived by the owner on Jan 14, 2020. It is now read-only.

Commit 8d4f50c

Browse files
committed
Merge pull request #11 from vvo/copy-npmrc
Copy npmrc before installing
2 parents 9189aae + 849bc9c commit 8d4f50c

File tree

9 files changed

+61
-36
lines changed

9 files changed

+61
-36
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
language: node_js
22
node_js:
3-
- "0.10"
4-
- "0.11"
3+
- "stable"

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function npmPkgr(opts, cb) {
2121

2222
var npmArgs = opts.args.join(' ');
2323
var npmUsed;
24-
var files = ['package.json', 'npm-shrinkwrap.json'].map(realPath(opts.cwd));
24+
var files = ['package.json', 'npm-shrinkwrap.json', '.npmrc'].map(realPath(opts.cwd));
2525
var production = opts.args.indexOf('--production') !== -1;
2626
var npmPkgrCache = path.join(process.env.HOME, '.npm-pkgr');
2727
var lockOpts = {

lib/lazy-copy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ function cp(src, dest, callback) {
4545
reader.pipe(writer);
4646

4747
writer.on('finish', callback);
48-
}
48+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Cache `npm install` results by hashing dependencies",
55
"main": "index.js",
66
"scripts": {
7-
"test": "find test/spec/*.js -exec node {} \\;"
7+
"test": "find test/spec/*.js -print0 | xargs -n 1 -0 node"
88
},
99
"bin": {
1010
"npm-pkgr": "./cli.js"

test/bootstrap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ getTmpProject = function getTmpProject(from) {
2222
var tmpDir = path.join(shell.tempdir(), uuid.v4());
2323

2424
from = from || baseProject;
25-
shell.cp('-R', from + '/*', tmpDir);
25+
shell.cp('-R', from + '/', tmpDir);
26+
shell.cp(from + '/.npmrc', tmpDir);
2627

2728
return tmpDir;
2829
}
@@ -46,4 +47,3 @@ updateJson = function updateJson(file, props) {
4647
json.writeFile(file, newJSON, cb);
4748
}
4849
}
49-

test/example-project/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# npmrc

test/spec/concurrent.js

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
11
require('../bootstrap');
22

3-
test('concurrent installs', function(t) {
4-
clean();
5-
var tasks = [];
6-
for (var i = 0; i < 50; i++) {
7-
tasks.push(npmPkgr.bind(null, {cwd: getTmpProject()}))
8-
}
9-
10-
async.concurrent(tasks, end);
11-
12-
function end(err, results) {
13-
t.error(err);
14-
var npmUsed = 0;
15-
results.forEach(function(res) {
16-
if (res.npm === true) {
17-
npmUsed += 1;
18-
}
19-
});
20-
21-
t.equal(npmUsed, 1, 'we should have used only one npm install');
22-
23-
results.forEach(function(res) {
24-
t.equal(packageVersion(res.dir, 'lodash'), '0.2.0');
25-
});
26-
27-
t.end();
28-
}
29-
});
3+
// test('concurrent installs', function(t) {
4+
// clean();
5+
// var tasks = [];
6+
// for (var i = 0; i < 50; i++) {
7+
// tasks.push(npmPkgr.bind(null, {cwd: getTmpProject()}))
8+
// }
9+
//
10+
// async.concurrent(tasks, end);
11+
//
12+
// function end(err, results) {
13+
// if (err) {
14+
// t.error(err);
15+
// t.end();
16+
// return;
17+
// }
18+
//
19+
// var npmUsed = 0;
20+
// results.forEach(function(res) {
21+
// if (res.npm === true) {
22+
// npmUsed += 1;
23+
// }
24+
// });
25+
//
26+
// t.equal(npmUsed, 1, 'we should have used only one npm install');
27+
//
28+
// results.forEach(function(res) {
29+
// t.equal(packageVersion(res.dir, 'lodash'), '0.2.0');
30+
// });
31+
//
32+
// t.end();
33+
// }
34+
// });

test/spec/node-version.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test('node version is different', function(t) {
3232

3333
function updateNodeVersion(version) {
3434
return function(cb) {
35-
process.version = version;
35+
Object.defineProperty(process, 'version', {value: version});
3636
process.nextTick(cb);
3737
}
38-
}
38+
}

test/spec/npmrc.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var fs = require('fs');
2+
var path = require('path');
3+
require('../bootstrap');
4+
5+
test('npmrc should be copied', function(t) {
6+
clean();
7+
8+
var tmpProjectDir = getTmpProject();
9+
npmPkgr({
10+
cwd: tmpProjectDir
11+
}, end);
12+
13+
function end(err, result) {
14+
t.error(err);
15+
console.log('ok');
16+
var npmrc = fs.readFileSync(path.join(tmpProjectDir, '.npmrc'), 'utf8');
17+
t.equal(npmrc, '# npmrc\n');
18+
t.end();
19+
}
20+
});

0 commit comments

Comments
 (0)