Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2015-08-05 05:34:04 +0300
committerRebecca Turner <me@re-becca.org>2015-08-08 02:06:46 +0300
commitd135abf5bbe11129edbe93672d97158d8c1c55f6 (patch)
tree3f104bd747fad7dfddeb7558ace713532caa4f4b /test
parent9c5193cf43539589c1ba00fe021a339d5341ae49 (diff)
install: Stop warning about package.json fields on global installs
(And removes.) PR-URL: https://github.com/npm/npm/pull/9167 Fixes: #8871
Diffstat (limited to 'test')
-rw-r--r--test/tap/no-global-warns.js67
1 files changed, 67 insertions, 0 deletions
diff --git a/test/tap/no-global-warns.js b/test/tap/no-global-warns.js
new file mode 100644
index 000000000..439388fe1
--- /dev/null
+++ b/test/tap/no-global-warns.js
@@ -0,0 +1,67 @@
+'use strict'
+var path = require('path')
+var test = require('tap').test
+var mkdirp = require('mkdirp')
+var osenv = require('osenv')
+var rimraf = require('rimraf')
+var writeFileSync = require('fs').writeFileSync
+var common = require('../common-tap.js')
+
+var base = path.join(__dirname, path.basename(__filename, '.js'))
+var mockGlobal = path.join(base, 'global')
+var toInstall = path.join(base, 'to-install')
+
+var config = 'prefix = ' + base
+var configPath = path.join(base, '_npmrc')
+
+var OPTS = {
+ env: {
+ 'npm_config_userconfig': configPath
+ }
+}
+
+var installJSON = {
+ name: 'to-install',
+ version: '1.0.0',
+ description: '',
+ main: 'index.js',
+ scripts: {
+ test: 'echo \"Error: no test specified\" && exit 1'
+ },
+ author: '',
+ license: 'ISC'
+}
+
+test('setup', function (t) {
+ setup()
+ t.end()
+})
+
+test('no-global-warns', function (t) {
+ common.npm(['install', '-g', toInstall], OPTS, function (err, code, stdout, stderr) {
+ t.ifError(err, 'installed w/o error')
+ t.is(stderr, '', 'no warnings printed to stderr')
+ t.end()
+ })
+})
+
+test('cleanup', function (t) {
+ process.chdir(osenv.tmpdir())
+ cleanup()
+ t.end()
+})
+
+function cleanup () {
+ rimraf.sync(base)
+}
+
+function setup () {
+ cleanup()
+ mkdirp.sync(mockGlobal)
+ mkdirp.sync(toInstall)
+ writeFileSync(
+ path.join(toInstall, 'package.json'),
+ JSON.stringify(installJSON, null, 2)
+ )
+ writeFileSync(configPath, config)
+}