1 var fs = require("graceful-fs")
2 var path = require("path")
3 var userconfigSrc = path.resolve(__dirname, "..", "fixtures", "config", "userconfig")
4 exports.userconfig = userconfigSrc + "-with-gc"
5 exports.globalconfig = path.resolve(__dirname, "..", "fixtures", "config", "globalconfig")
6 exports.builtin = path.resolve(__dirname, "..", "fixtures", "config", "builtin")
7 exports.malformed = path.resolve(__dirname, "..", "fixtures", "config", "malformed")
9 { globalconfig: exports.globalconfig,
12 "init.author.name": "Isaac Z. Schlueter",
13 "init.author.email": "i@izs.me",
14 "init.author.url": "http://blog.izs.me/",
15 "init.version": "1.2.3",
16 "proprietary-attribs": false,
17 "npm:publishtest": true,
18 "_npmjs.org:couch": "https://admin:password@localhost:5984/registry",
19 "npm-www:nocache": "1",
20 nodedir: "/Users/isaacs/dev/js/node-v0.8",
24 "tmp": process.env.HOME + "/.tmp",
25 _auth: "dXNlcm5hbWU6cGFzc3dvcmQ=",
27 { AuthSession: "yabba-dabba-doodle",
29 expires: "1345001053415",
33 // set the userconfig in the env
34 // unset anything else that npm might be trying to foist on us
35 Object.keys(process.env).forEach(function (k) {
36 if (k.match(/^npm_config_/i)) {
40 process.env.npm_config_userconfig = exports.userconfig
41 process.env.npm_config_other_env_thing = 1000
42 process.env.random_env_var = "asdf"
43 process.env.npm_config__underbar_env_thing = "underful"
44 process.env.NPM_CONFIG_UPPERCASE_ENV_THING = 42
47 userconfig: exports.userconfig,
48 "_underbar-env-thing": "underful",
49 "uppercase-env-thing": "42",
50 "other-env-thing": "1000"
52 exports.envDataFix = {
53 userconfig: exports.userconfig,
54 "_underbar-env-thing": "underful",
55 "uppercase-env-thing": 42,
56 "other-env-thing": 1000
59 var projectConf = path.resolve(__dirname, '..', '..', '.npmrc')
61 fs.statSync(projectConf)
63 // project conf not found, probably working with packed npm
64 fs.writeFileSync(projectConf, 'save-prefix = ~\nproprietary-attribs = false\n')
67 var projectRc = path.join(__dirname, '..', 'fixtures', 'config', '.npmrc')
69 fs.statSync(projectRc)
71 // project conf not found, probably working with packed npm
72 fs.writeFileSync(projectRc, 'just = testing')
75 if (module === require.main) {
76 // set the globalconfig in the userconfig
77 var uc = fs.readFileSync(userconfigSrc)
78 var gcini = "globalconfig = " + exports.globalconfig + "\n"
79 fs.writeFileSync(exports.userconfig, gcini + uc)
82 console.log("ok 1 setup done")