Server IP : 127.0.0.2 / Your IP : 18.217.0.242 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/npm/node_modules/init-package-json/test/ |
Upload File : |
var test = require('tap').test var rimraf = require('rimraf') var resolve = require('path').resolve var npm = require('npm') var init = require('../') var EXPECTED = { name: 'test', version: '3.1.4', description: '', main: 'basic.js', scripts: { test: 'echo "Error: no test specified" && exit 1' }, keywords: [], author: 'npmbot <n@p.m> (http://npm.im/)', license: 'WTFPL' } test('npm configuration values pulled from environment', function (t) { /*eslint camelcase:0 */ process.env.npm_config_yes = 'yes' process.env.npm_config_init_author_name = 'npmbot' process.env.npm_config_init_author_email = 'n@p.m' process.env.npm_config_init_author_url = 'http://npm.im' process.env.npm_config_init_license = EXPECTED.license process.env.npm_config_init_version = EXPECTED.version npm.load({}, function (err) { t.ifError(err, 'npm loaded successfully') // clear out dotted names from test environment npm.config.del('init.author.name') npm.config.del('init.author.email') npm.config.del('init.author.url') // the following have npm defaults, and need to be explicitly overridden npm.config.set('init.license', '') npm.config.set('init.version', '') process.chdir(resolve(__dirname)) init(__dirname, __dirname, npm.config, function (er, data) { t.ifError(err, 'init ran successfully') t.same(data, EXPECTED, 'got the package data from the environment') t.end() }) }) }) test('npm configuration values pulled from dotted config', function (t) { /*eslint camelcase:0 */ var config = { yes: 'yes', 'init.author.name': 'npmbot', 'init.author.email': 'n@p.m', 'init.author.url': 'http://npm.im', 'init.license': EXPECTED.license, 'init.version': EXPECTED.version } npm.load(config, function (err) { t.ifError(err, 'npm loaded successfully') process.chdir(resolve(__dirname)) init(__dirname, __dirname, npm.config, function (er, data) { t.ifError(err, 'init ran successfully') t.same(data, EXPECTED, 'got the package data from the config') t.end() }) }) }) test('npm configuration values pulled from dashed config', function (t) { /*eslint camelcase:0 */ var config = { yes: 'yes', 'init-author-name': 'npmbot', 'init-author-email': 'n@p.m', 'init-author-url': 'http://npm.im', 'init-license': EXPECTED.license, 'init-version': EXPECTED.version } npm.load(config, function (err) { t.ifError(err, 'npm loaded successfully') process.chdir(resolve(__dirname)) init(__dirname, __dirname, npm.config, function (er, data) { t.ifError(err, 'init ran successfully') t.same(data, EXPECTED, 'got the package data from the config') t.end() }) }) }) test('cleanup', function (t) { rimraf.sync(resolve(__dirname, 'package.json')) t.pass('cleaned up') t.end() })