Skip to content

Commit 118f48c

Browse files
zkatrvagg
authored andcommitted
deps: create .npmrc during npm tests
This patch should make the tests pass on the downstreamed npm. PR-URL: #2696 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Rod Vagg <[email protected]>
1 parent b3fee8e commit 118f48c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

deps/npm/test/tap/00-config-setup.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var fs = require("graceful-fs")
12
var path = require("path")
23
var userconfigSrc = path.resolve(__dirname, "..", "fixtures", "config", "userconfig")
34
exports.userconfig = userconfigSrc + "-with-gc"
@@ -55,10 +56,24 @@ exports.envDataFix = {
5556
"other-env-thing": 1000
5657
}
5758

59+
var projectConf = path.resolve(__dirname, '..', '..', '.npmrc')
60+
try {
61+
fs.statSync(projectConf)
62+
} catch (er) {
63+
// project conf not found, probably working with packed npm
64+
fs.writeFileSync(projectConf, 'save-prefix = ~\nproprietary-attribs = false\n')
65+
}
66+
67+
var projectRc = path.join(__dirname, '..', 'fixtures', 'config', '.npmrc')
68+
try {
69+
fs.statSync(projectRc)
70+
} catch (er) {
71+
// project conf not found, probably working with packed npm
72+
fs.writeFileSync(projectRc, 'just = testing')
73+
}
5874

5975
if (module === require.main) {
6076
// set the globalconfig in the userconfig
61-
var fs = require("fs")
6277
var uc = fs.readFileSync(userconfigSrc)
6378
var gcini = "globalconfig = " + exports.globalconfig + "\n"
6479
fs.writeFileSync(exports.userconfig, gcini + uc)

0 commit comments

Comments
 (0)