• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1var fs = require('graceful-fs')
2var path = require('path')
3var userconfigSrc = path.resolve(__dirname, '..', 'fixtures', 'config', 'userconfig')
4exports.userconfig = userconfigSrc + '-with-gc'
5exports.globalconfig = path.resolve(__dirname, '..', 'fixtures', 'config', 'globalconfig')
6exports.builtin = path.resolve(__dirname, '..', 'fixtures', 'config', 'builtin')
7exports.malformed = path.resolve(__dirname, '..', 'fixtures', 'config', 'malformed')
8exports.ucData =
9  { globalconfig: exports.globalconfig,
10    email: 'i@izs.me',
11    'env-thing': 'asdf',
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    'npm:publishtest': true,
17    '_npmjs.org:couch': 'https://admin:password@localhost:5984/registry',
18    'npm-www:nocache': '1',
19    nodedir: '/Users/isaacs/dev/js/node-v0.8',
20    'sign-git-tag': true,
21    message: 'v%s',
22    'strict-ssl': false,
23    'tmp': path.normalize(process.env.HOME + '/.tmp'),
24    _auth: 'dXNlcm5hbWU6cGFzc3dvcmQ=',
25    _token:
26     { AuthSession: 'yabba-dabba-doodle',
27       version: '1',
28       expires: '1345001053415',
29       path: '/',
30       httponly: true } }
31
32// set the userconfig in the env
33// unset anything else that npm might be trying to foist on us
34Object.keys(process.env).forEach(function (k) {
35  if (k.match(/^npm_config_/i)) {
36    delete process.env[k]
37  }
38})
39process.env.npm_config_userconfig = exports.userconfig
40process.env.npm_config_other_env_thing = '1000'
41process.env.random_env_var = 'asdf'
42process.env.npm_config__underbar_env_thing = 'underful'
43process.env.NPM_CONFIG_UPPERCASE_ENV_THING = '42'
44
45exports.envData = {
46  userconfig: exports.userconfig,
47  '_underbar-env-thing': 'underful',
48  'uppercase-env-thing': '42',
49  'other-env-thing': '1000'
50}
51exports.envDataFix = {
52  userconfig: exports.userconfig,
53  '_underbar-env-thing': 'underful',
54  'uppercase-env-thing': 42,
55  'other-env-thing': 1000
56}
57
58var projectConf = path.resolve(__dirname, '..', '..', '.npmrc')
59try {
60  fs.statSync(projectConf)
61} catch (er) {
62  // project conf not found, probably working with packed npm
63  fs.writeFileSync(projectConf, function () { /*
64save-prefix = ~
65legacy-bundling = true
66  */ }.toString().split('\n').slice(1, -1).join('\n'))
67}
68
69var projectRc = path.join(__dirname, '..', 'fixtures', 'config', '.npmrc')
70try {
71  fs.statSync(projectRc)
72} catch (er) {
73  // project conf not found, probably working with packed npm
74  fs.writeFileSync(projectRc, 'just = testing')
75}
76
77if (module === require.main) {
78  // set the globalconfig in the userconfig
79  var uc = fs.readFileSync(userconfigSrc)
80  var gcini = 'globalconfig = ' + exports.globalconfig + '\n'
81  fs.writeFileSync(exports.userconfig, gcini + uc)
82
83  console.log('1..1')
84  console.log('ok 1 setup done')
85}
86