1var test = require('tap').test 2var common = require('../common-config.js') 3var npmconf = require('../../lib/config/core.js') 4var path = require('path') 5 6var projectData = { 7} 8 9var ucData = common.ucData 10var envData = common.envData 11 12var gcData = { 'package-config:foo': 'boo' } 13 14var biData = {} 15 16var cli = { foo: 'bar', umask: parseInt('022', 8) } 17 18var expectNames = [ 19 'cli', 20 'envData', 21 'projectData', 22 'ucData', 23 'gcData', 24 'biData' 25] 26var expectList = [ 27 cli, 28 envData, 29 projectData, 30 ucData, 31 gcData, 32 biData 33] 34 35var expectSources = { 36 cli: { data: cli }, 37 env: { 38 data: envData, 39 source: envData, 40 prefix: '' 41 }, 42 project: { 43 path: path.resolve(__dirname, '..', '..', '.npmrc'), 44 type: 'ini', 45 data: projectData 46 }, 47 user: { 48 path: common.userconfig, 49 type: 'ini', 50 data: ucData 51 }, 52 global: { 53 path: common.globalconfig, 54 type: 'ini', 55 data: gcData 56 }, 57 builtin: { data: biData } 58} 59 60function isDeeplyDetails (t, aa, bb, msg, seen) { 61 return t.same(aa, bb, msg) 62} 63 64test('no builtin', function (t) { 65 t.comment(process.env) 66 npmconf.load(cli, function (er, conf) { 67 if (er) throw er 68 expectNames.forEach(function (name, ii) { 69 isDeeplyDetails(t, conf.list[ii], expectList[ii], 'config properties list: ' + name) 70 }) 71 isDeeplyDetails(t, conf.sources, expectSources, 'config by source') 72 t.same(npmconf.rootConf.list, [], 'root configuration is empty') 73 isDeeplyDetails(t, npmconf.rootConf.root, npmconf.defs.defaults, 'defaults') 74 isDeeplyDetails(t, conf.root, npmconf.defs.defaults, 'current root config is defaults') 75 t.is(conf.get('umask'), parseInt('022', 8), 'umask is as expected') 76 t.is(conf.get('heading'), 'npm', 'config name is as expected') 77 t.end() 78 }) 79}) 80