]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/init-package-json/test/npm-defaults.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / init-package-json / test / npm-defaults.js
1 var test = require('tap').test
2 var rimraf = require('rimraf')
3 var resolve = require('path').resolve
4
5 var npm = require('npm')
6 var init = require('../')
7
8 var EXPECTED = {
9   name: 'test',
10   version: '3.1.4',
11   description: '',
12   main: 'basic.js',
13   scripts: {
14     test: 'echo "Error: no test specified" && exit 1'
15   },
16   keywords: [],
17   author: 'npmbot <n@p.m> (http://npm.im/)',
18   license: 'WTFPL'
19 }
20
21 test('npm configuration values pulled from environment', function (t) {
22   /*eslint camelcase:0 */
23   process.env.npm_config_yes = 'yes'
24
25   process.env.npm_config_init_author_name = 'npmbot'
26   process.env.npm_config_init_author_email = 'n@p.m'
27   process.env.npm_config_init_author_url = 'http://npm.im'
28
29   process.env.npm_config_init_license = EXPECTED.license
30   process.env.npm_config_init_version = EXPECTED.version
31
32   npm.load({}, function (err) {
33     t.ifError(err, 'npm loaded successfully')
34
35     // clear out dotted names from test environment
36     npm.config.del('init.author.name')
37     npm.config.del('init.author.email')
38     npm.config.del('init.author.url')
39     // the following have npm defaults, and need to be explicitly overridden
40     npm.config.set('init.license', '')
41     npm.config.set('init.version', '')
42
43     process.chdir(resolve(__dirname))
44     init(__dirname, __dirname, npm.config, function (er, data) {
45       t.ifError(err, 'init ran successfully')
46
47       t.same(data, EXPECTED, 'got the package data from the environment')
48       t.end()
49     })
50   })
51 })
52
53 test('npm configuration values pulled from dotted config', function (t) {
54   /*eslint camelcase:0 */
55   var config = {
56     yes: 'yes',
57
58     'init.author.name': 'npmbot',
59     'init.author.email': 'n@p.m',
60     'init.author.url': 'http://npm.im',
61
62     'init.license': EXPECTED.license,
63     'init.version': EXPECTED.version
64   }
65
66   npm.load(config, function (err) {
67     t.ifError(err, 'npm loaded successfully')
68
69     process.chdir(resolve(__dirname))
70     init(__dirname, __dirname, npm.config, function (er, data) {
71       t.ifError(err, 'init ran successfully')
72
73       t.same(data, EXPECTED, 'got the package data from the config')
74       t.end()
75     })
76   })
77 })
78
79 test('npm configuration values pulled from dashed config', function (t) {
80   /*eslint camelcase:0 */
81   var config = {
82     yes: 'yes',
83
84     'init-author-name': 'npmbot',
85     'init-author-email': 'n@p.m',
86     'init-author-url': 'http://npm.im',
87
88     'init-license': EXPECTED.license,
89     'init-version': EXPECTED.version
90   }
91
92   npm.load(config, function (err) {
93     t.ifError(err, 'npm loaded successfully')
94
95     process.chdir(resolve(__dirname))
96     init(__dirname, __dirname, npm.config, function (er, data) {
97       t.ifError(err, 'init ran successfully')
98
99       t.same(data, EXPECTED, 'got the package data from the config')
100       t.end()
101     })
102   })
103 })
104
105 test('cleanup', function (t) {
106   rimraf.sync(resolve(__dirname, 'package.json'))
107   t.pass('cleaned up')
108   t.end()
109 })