|
| 1 | +if (module === require.main) { |
| 2 | + console.log('1..1') |
| 3 | + console.log('ok 1 setup done') |
| 4 | + process.exit(0) |
| 5 | +} |
| 6 | + |
| 7 | +var fs = require('graceful-fs') |
| 8 | +var path = require('path') |
| 9 | +var userconfigSrc = path.resolve(__dirname, 'fixtures', 'config', 'userconfig') |
| 10 | +exports.userconfig = userconfigSrc + '-with-gc' |
| 11 | +exports.globalconfig = path.resolve(__dirname, 'fixtures', 'config', 'globalconfig') |
| 12 | + |
| 13 | +// if this hasn't been written yet, then do it now. |
| 14 | +try { |
| 15 | + fs.statSync(exports.userconfig) |
| 16 | +} catch (er) { |
| 17 | + var uc = fs.readFileSync(userconfigSrc) |
| 18 | + var gcini = 'globalconfig = ' + exports.globalconfig + '\n' |
| 19 | + // atomic! |
| 20 | + fs.writeFileSync(exports.userconfig + '.' + process.pid, gcini + uc) |
| 21 | + fs.renameSync(exports.userconfig + '.' + process.pid, exports.userconfig) |
| 22 | +} |
| 23 | + |
| 24 | +exports.builtin = path.resolve(__dirname, 'fixtures', 'config', 'builtin') |
| 25 | +exports.malformed = path.resolve(__dirname, 'fixtures', 'config', 'malformed') |
| 26 | +exports.ucData = |
| 27 | + { globalconfig: exports.globalconfig, |
| 28 | + email: 'i@izs.me', |
| 29 | + 'env-thing': 'asdf', |
| 30 | + 'init.author.name': 'Isaac Z. Schlueter', |
| 31 | + 'init.author.email': 'i@izs.me', |
| 32 | + 'init.author.url': 'http://blog.izs.me/', |
| 33 | + 'init.version': '1.2.3', |
| 34 | + 'npm:publishtest': true, |
| 35 | + '_npmjs.org:couch': 'https://admin:password@localhost:5984/registry', |
| 36 | + 'npm-www:nocache': '1', |
| 37 | + nodedir: '/Users/isaacs/dev/js/node-v0.8', |
| 38 | + 'sign-git-tag': true, |
| 39 | + message: 'v%s', |
| 40 | + 'strict-ssl': false, |
| 41 | + 'tmp': path.normalize(process.env.HOME + '/.tmp'), |
| 42 | + _auth: 'dXNlcm5hbWU6cGFzc3dvcmQ=', |
| 43 | + _token: |
| 44 | + { AuthSession: 'yabba-dabba-doodle', |
| 45 | + version: '1', |
| 46 | + expires: '1345001053415', |
| 47 | + path: '/', |
| 48 | + httponly: true } } |
| 49 | + |
| 50 | +// set the userconfig in the env |
| 51 | +// unset anything else that npm might be trying to foist on us |
| 52 | +Object.keys(process.env).forEach(function (k) { |
| 53 | + if (k.match(/^npm_config_/i)) { |
| 54 | + delete process.env[k] |
| 55 | + } |
| 56 | +}) |
| 57 | +process.env.npm_config_userconfig = exports.userconfig |
| 58 | +process.env.npm_config_other_env_thing = '1000' |
| 59 | +process.env.random_env_var = 'asdf' |
| 60 | +process.env.npm_config__underbar_env_thing = 'underful' |
| 61 | +process.env.NPM_CONFIG_UPPERCASE_ENV_THING = '42' |
| 62 | + |
| 63 | +exports.envData = { |
| 64 | + userconfig: exports.userconfig, |
| 65 | + '_underbar-env-thing': 'underful', |
| 66 | + 'uppercase-env-thing': '42', |
| 67 | + 'other-env-thing': '1000' |
| 68 | +} |
| 69 | +exports.envDataFix = { |
| 70 | + userconfig: exports.userconfig, |
| 71 | + '_underbar-env-thing': 'underful', |
| 72 | + 'uppercase-env-thing': 42, |
| 73 | + 'other-env-thing': 1000 |
| 74 | +} |
| 75 | + |
| 76 | +var projectConf = path.resolve(__dirname, '..', '.npmrc') |
| 77 | +try { |
| 78 | + fs.statSync(projectConf) |
| 79 | +} catch (er) { |
| 80 | + // project conf not found, probably working with packed npm |
| 81 | + fs.writeFileSync(projectConf, '') |
| 82 | +} |
| 83 | + |
| 84 | +var projectRc = path.join(__dirname, 'fixtures', 'config', '.npmrc') |
| 85 | +try { |
| 86 | + fs.statSync(projectRc) |
| 87 | +} catch (er) { |
| 88 | + // project conf not found, probably working with packed npm |
| 89 | + fs.writeFileSync(projectRc, 'just = testing') |
| 90 | +} |
0 commit comments