diff --git a/docs/lib/content/commands/npm-doctor.md b/docs/lib/content/commands/npm-doctor.md index 3abb1e29a24e2..5682f20b4cb5b 100644 --- a/docs/lib/content/commands/npm-doctor.md +++ b/docs/lib/content/commands/npm-doctor.md @@ -31,8 +31,10 @@ Also, in addition to this, there are also very many issue reports due to using old versions of npm. Since npm is constantly improving, running `npm@latest` is better than an old version. -`npm doctor` verifies the following items in your environment, and if there -are any recommended changes, it will display them. +`npm doctor` verifies the following items in your environment, and if +there are any recommended changes, it will display them. By default npm +runs all of these checks. You can limit what checks are ran by +specifying them as extra arguments. #### `npm ping` diff --git a/lib/commands/doctor.js b/lib/commands/doctor.js index f5bee1eb83f6c..19262e537dbe0 100644 --- a/lib/commands/doctor.js +++ b/lib/commands/doctor.js @@ -1,14 +1,13 @@ const cacache = require('cacache') const fs = require('fs') const fetch = require('make-fetch-happen') -const table = require('text-table') +const Table = require('cli-table3') const which = require('which') const pacote = require('pacote') const { resolve } = require('path') const semver = require('semver') const { promisify } = require('util') const log = require('../utils/log-shim.js') -const ansiTrim = require('../utils/ansi-trim.js') const ping = require('../utils/ping.js') const { registry: { default: defaultRegistry }, @@ -17,6 +16,7 @@ const lstat = promisify(fs.lstat) const readdir = promisify(fs.readdir) const access = promisify(fs.access) const { R_OK, W_OK, X_OK } = fs.constants + const maskLabel = mask => { const label = [] if (mask & R_OK) { @@ -34,76 +34,105 @@ const maskLabel = mask => { return label.join(', ') } +const subcommands = [ + { + groups: ['ping', 'registry'], + title: 'npm ping', + cmd: 'checkPing', + }, { + groups: ['versions'], + title: 'npm -v', + cmd: 'getLatestNpmVersion', + }, { + groups: ['versions'], + title: 'node -v', + cmd: 'getLatestNodejsVersion', + }, { + groups: ['registry'], + title: 'npm config get registry', + cmd: 'checkNpmRegistry', + }, { + groups: ['environment'], + title: 'git executable in PATH', + cmd: 'getGitPath', + }, { + groups: ['environment'], + title: 'global bin folder in PATH', + cmd: 'getBinPath', + }, { + groups: ['permissions', 'cache'], + title: 'Perms check on cached files', + cmd: 'checkCachePermission', + windows: false, + }, { + groups: ['permissions'], + title: 'Perms check on local node_modules', + cmd: 'checkLocalModulesPermission', + windows: false, + }, { + groups: ['permissions'], + title: 'Perms check on global node_modules', + cmd: 'checkGlobalModulesPermission', + windows: false, + }, { + groups: ['permissions'], + title: 'Perms check on local bin folder', + cmd: 'checkLocalBinPermission', + windows: false, + }, { + groups: ['permissions'], + title: 'Perms check on global bin folder', + cmd: 'checkGlobalBinPermission', + windows: false, + }, { + groups: ['cache'], + title: 'Verify cache contents', + cmd: 'verifyCachedFiles', + windows: false, + }, + // TODO: + // group === 'dependencies'? + // - ensure arborist.loadActual() runs without errors and no invalid edges + // - ensure package-lock.json matches loadActual() + // - verify loadActual without hidden lock file matches hidden lockfile + // group === '???' + // - verify all local packages have bins linked + // What is the fix for these? +] const BaseCommand = require('../base-command.js') class Doctor extends BaseCommand { static description = 'Check your npm environment' static name = 'doctor' static params = ['registry'] static ignoreImplicitWorkspace = false + static usage = [`[${subcommands.flatMap(s => s.groups) + .filter((value, index, self) => self.indexOf(value) === index) + .join('] [')}]`] + + static subcommands = subcommands + + // minimum width of check column, enough for the word `Check` + #checkWidth = 5 async exec (args) { log.info('Running checkup') + let allOk = true - // each message is [title, ok, message] - const messages = [] - - const actions = [ - ['npm ping', 'checkPing', []], - ['npm -v', 'getLatestNpmVersion', []], - ['node -v', 'getLatestNodejsVersion', []], - ['npm config get registry', 'checkNpmRegistry', []], - ['which git', 'getGitPath', []], - ...(process.platform === 'win32' - ? [] - : [ - [ - 'Perms check on cached files', - 'checkFilesPermission', - [this.npm.cache, true, R_OK], - ], [ - 'Perms check on local node_modules', - 'checkFilesPermission', - [this.npm.localDir, true, R_OK | W_OK, true], - ], [ - 'Perms check on global node_modules', - 'checkFilesPermission', - [this.npm.globalDir, false, R_OK], - ], [ - 'Perms check on local bin folder', - 'checkFilesPermission', - [this.npm.localBin, false, R_OK | W_OK | X_OK, true], - ], [ - 'Perms check on global bin folder', - 'checkFilesPermission', - [this.npm.globalBin, false, X_OK], - ], - ]), - [ - 'Verify cache contents', - 'verifyCachedFiles', - [this.npm.flatOptions.cache], - ], - // TODO: - // - ensure arborist.loadActual() runs without errors and no invalid edges - // - ensure package-lock.json matches loadActual() - // - verify loadActual without hidden lock file matches hidden lockfile - // - verify all local packages have bins linked - ] + const actions = this.actions(args) + this.#checkWidth = actions.reduce((length, item) => + Math.max(item.title.length, length), this.#checkWidth) + if (!this.npm.silent) { + this.output(['Check', 'Value', 'Recommendation/Notes'].map(h => this.npm.chalk.underline(h))) + } // Do the actual work - for (const [msg, fn, args] of actions) { - const line = [msg] + for (const { title, cmd } of actions) { + const item = [title] try { - line.push(true, await this[fn](...args)) - } catch (er) { - line.push(false, er) + item.push(true, await this[cmd]()) + } catch (err) { + item.push(false, err) } - messages.push(line) - } - - const outHead = ['Check', 'Value', 'Recommendation/Notes'].map(h => this.npm.chalk.underline(h)) - let allOk = true - const outBody = messages.map(item => { if (!item[1]) { allOk = false item[0] = this.npm.chalk.red(item[0]) @@ -112,18 +141,18 @@ class Doctor extends BaseCommand { } else { item[1] = this.npm.chalk.green('ok') } - return item - }) - const outTable = [outHead, ...outBody] - const tableOpts = { - stringLength: s => ansiTrim(s).length, + if (!this.npm.silent) { + this.output(item) + } } - if (!this.npm.silent) { - this.npm.output(table(outTable, tableOpts)) - } if (!allOk) { - throw new Error('Some problems found. See above for recommendations.') + if (this.npm.silent) { + /* eslint-disable-next-line max-len */ + throw new Error('Some problems found. Check logs or disable silent mode for recommendations.') + } else { + throw new Error('Some problems found. See above for recommendations.') + } } } @@ -191,6 +220,35 @@ class Doctor extends BaseCommand { } } + async getBinPath (dir) { + const tracker = log.newItem('getBinPath', 1) + tracker.info('getBinPath', 'Finding npm global bin in your PATH') + if (!process.env.PATH.includes(this.npm.globalBin)) { + throw new Error(`Add ${this.npm.globalBin} to your $PATH`) + } + return this.npm.globalBin + } + + async checkCachePermission () { + return this.checkFilesPermission(this.npm.cache, true, R_OK) + } + + async checkLocalModulesPermission () { + return this.checkFilesPermission(this.npm.localDir, true, R_OK | W_OK, true) + } + + async checkGlobalModulesPermission () { + return this.checkFilesPermission(this.npm.globalDir, false, R_OK) + } + + async checkLocalBinPermission () { + return this.checkFilesPermission(this.npm.localBin, false, R_OK | W_OK | X_OK, true) + } + + async checkGlobalBinPermission () { + return this.checkFilesPermission(this.npm.globalBin, false, X_OK) + } + async checkFilesPermission (root, shouldOwn, mask, missingOk) { let ok = true @@ -264,7 +322,7 @@ class Doctor extends BaseCommand { try { return await which('git').catch(er => { tracker.warn(er) - throw "Install git and ensure it's in your PATH." + throw new Error("Install git and ensure it's in your PATH.") }) } finally { tracker.finish() @@ -312,6 +370,42 @@ class Doctor extends BaseCommand { return `using default registry (${defaultRegistry})` } } + + output (row) { + const t = new Table({ + chars: { top: '', + 'top-mid': '', + 'top-left': '', + 'top-right': '', + bottom: '', + 'bottom-mid': '', + 'bottom-left': '', + 'bottom-right': '', + left: '', + 'left-mid': '', + mid: '', + 'mid-mid': '', + right: '', + 'right-mid': '', + middle: ' ' }, + style: { 'padding-left': 0, 'padding-right': 0 }, + colWidths: [this.#checkWidth, 6], + }) + t.push(row) + this.npm.output(t.toString()) + } + + actions (params) { + return this.constructor.subcommands.filter(subcmd => { + if (process.platform === 'win32' && subcmd.windows === false) { + return false + } + if (params.length) { + return params.some(param => subcmd.groups.includes(param)) + } + return true + }) + } } module.exports = Doctor diff --git a/tap-snapshots/test/lib/commands/doctor.js.test.cjs b/tap-snapshots/test/lib/commands/doctor.js.test.cjs index d84d7d368580c..8d21f98e4892c 100644 --- a/tap-snapshots/test/lib/commands/doctor.js.test.cjs +++ b/tap-snapshots/test/lib/commands/doctor.js.test.cjs @@ -28,6 +28,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -49,33 +53,35 @@ Object { ` exports[`test/lib/commands/doctor.js TAP all clear > output 1`] = ` -Check Value Recommendation/Notes -npm ping ok -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files ok -Perms check on local node_modules ok -Perms check on global node_modules ok -Perms check on local bin folder ok -Perms check on global bin folder ok -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  ok   +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-all-clear/global/bin +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +Verify cache contents  ok  verified 0 tarballs ` exports[`test/lib/commands/doctor.js TAP all clear in color > everything is ok in color 1`] = ` -Check Value Recommendation/Notes -npm ping ok -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files ok -Perms check on local node_modules ok -Perms check on global node_modules ok -Perms check on local bin folder ok -Perms check on global bin folder ok -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  ok   +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-all-clear-in-color/global/bin +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +Verify cache contents  ok  verified 0 tarballs ` exports[`test/lib/commands/doctor.js TAP all clear in color > logs 1`] = ` @@ -101,6 +107,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -144,6 +154,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -165,33 +179,35 @@ Object { ` exports[`test/lib/commands/doctor.js TAP bad proxy > output 1`] = ` -Check Value Recommendation/Notes -npm ping not ok unsupported proxy protocol: 'ssh:' -npm -v not ok Error: unsupported proxy protocol: 'ssh:' -node -v not ok Error: unsupported proxy protocol: 'ssh:' -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files ok -Perms check on local node_modules ok -Perms check on global node_modules ok -Perms check on local bin folder ok -Perms check on global bin folder ok -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  not ok unsupported proxy protocol: 'ssh:' +npm -v  not ok Error: unsupported proxy protocol: 'ssh:' +node -v  not ok Error: unsupported proxy protocol: 'ssh:' +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-bad-proxy/global/bin +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +Verify cache contents  ok  verified 0 tarballs ` exports[`test/lib/commands/doctor.js TAP cacache badContent > corrupted cache content 1`] = ` -Check Value Recommendation/Notes -npm ping ok -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files ok -Perms check on local node_modules ok -Perms check on global node_modules ok -Perms check on local bin folder ok -Perms check on global bin folder ok -Verify cache contents ok verified 2 tarballs +Check  Value  Recommendation/Notes +npm ping  ok   +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-cacache-badContent/global/bin +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +Verify cache contents  ok  verified 2 tarballs ` exports[`test/lib/commands/doctor.js TAP cacache badContent > logs 1`] = ` @@ -217,6 +233,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -269,6 +289,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -299,33 +323,35 @@ Object { ` exports[`test/lib/commands/doctor.js TAP cacache missingContent > missing content 1`] = ` -Check Value Recommendation/Notes -npm ping ok -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files ok -Perms check on local node_modules ok -Perms check on global node_modules ok -Perms check on local bin folder ok -Perms check on global bin folder ok -Verify cache contents ok verified 2 tarballs +Check  Value  Recommendation/Notes +npm ping  ok   +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-cacache-missingContent/global/bin +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +Verify cache contents  ok  verified 2 tarballs ` exports[`test/lib/commands/doctor.js TAP cacache reclaimedCount > content garbage collected 1`] = ` -Check Value Recommendation/Notes -npm ping ok -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files ok -Perms check on local node_modules ok -Perms check on global node_modules ok -Perms check on local bin folder ok -Perms check on global bin folder ok -Verify cache contents ok verified 2 tarballs +Check  Value  Recommendation/Notes +npm ping  ok   +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-cacache-reclaimedCount/global/bin +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +Verify cache contents  ok  verified 2 tarballs ` exports[`test/lib/commands/doctor.js TAP cacache reclaimedCount > logs 1`] = ` @@ -351,6 +377,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -380,6 +410,187 @@ Object { } ` +exports[`test/lib/commands/doctor.js TAP discrete checks cache > logs 1`] = ` +Object { + "error": Array [], + "info": Array [ + Array [ + "Running checkup", + ], + Array [ + "verifyCachedFiles", + "Verifying the npm cache", + ], + Array [ + "verifyCachedFiles", + String( + Verification complete. Stats: { + "badContentCount": 0, + "reclaimedCount": 0, + "missingContent": 0, + "verifiedContent": 0 + } + ), + ], + ], + "warn": Array [], +} +` + +exports[`test/lib/commands/doctor.js TAP discrete checks cache > output 1`] = ` +Check  Value  Recommendation/Notes +Perms check on cached files ok   +Verify cache contents  ok  verified 0 tarballs +` + +exports[`test/lib/commands/doctor.js TAP discrete checks git > logs 1`] = ` +Object { + "error": Array [], + "info": Array [ + Array [ + "Running checkup", + ], + ], + "warn": Array [], +} +` + +exports[`test/lib/commands/doctor.js TAP discrete checks git > output 1`] = ` +Check Value  Recommendation/Notes +` + +exports[`test/lib/commands/doctor.js TAP discrete checks invalid environment > logs 1`] = ` +Object { + "error": Array [], + "info": Array [ + Array [ + "Running checkup", + ], + Array [ + "getGitPath", + "Finding git in your PATH", + ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], + ], + "warn": Array [], +} +` + +exports[`test/lib/commands/doctor.js TAP discrete checks invalid environment > output 1`] = ` +Check  Value  Recommendation/Notes +git executable in PATH  ok  /path/to/git +global bin folder in PATH not ok Error: Add {CWD}/test/lib/commands/tap-testdir-doctor-discrete-checks-invalid-environment/global/bin to your $PATH +` + +exports[`test/lib/commands/doctor.js TAP discrete checks permissions - not windows > logs 1`] = ` +Object { + "error": Array [], + "info": Array [ + Array [ + "Running checkup", + ], + ], + "warn": Array [], +} +` + +exports[`test/lib/commands/doctor.js TAP discrete checks permissions - not windows > output 1`] = ` +Check  Value  Recommendation/Notes +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +` + +exports[`test/lib/commands/doctor.js TAP discrete checks permissions - windows > logs 1`] = ` +Object { + "error": Array [], + "info": Array [ + Array [ + "Running checkup", + ], + ], + "warn": Array [], +} +` + +exports[`test/lib/commands/doctor.js TAP discrete checks permissions - windows > output 1`] = ` +Check Value  Recommendation/Notes +` + +exports[`test/lib/commands/doctor.js TAP discrete checks ping > logs 1`] = ` +Object { + "error": Array [], + "info": Array [ + Array [ + "Running checkup", + ], + Array [ + "checkPing", + "Pinging registry", + ], + ], + "warn": Array [], +} +` + +exports[`test/lib/commands/doctor.js TAP discrete checks ping > output 1`] = ` +Check  Value  Recommendation/Notes +npm ping ok   +` + +exports[`test/lib/commands/doctor.js TAP discrete checks registry > logs 1`] = ` +Object { + "error": Array [], + "info": Array [ + Array [ + "Running checkup", + ], + Array [ + "checkPing", + "Pinging registry", + ], + ], + "warn": Array [], +} +` + +exports[`test/lib/commands/doctor.js TAP discrete checks registry > output 1`] = ` +Check  Value  Recommendation/Notes +npm ping  ok   +npm config get registry ok  using default registry (https://registry.npmjs.org/) +` + +exports[`test/lib/commands/doctor.js TAP discrete checks versions > logs 1`] = ` +Object { + "error": Array [], + "info": Array [ + Array [ + "Running checkup", + ], + Array [ + "getLatestNpmVersion", + "Getting npm package information", + ], + Array [ + "getLatestNodejsVersion", + "Getting Node.js release information", + ], + ], + "warn": Array [], +} +` + +exports[`test/lib/commands/doctor.js TAP discrete checks versions > output 1`] = ` +Check  Value  Recommendation/Notes +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v ok  current: v1.0.0, recommended: v1.0.0 +` + exports[`test/lib/commands/doctor.js TAP error reading directory > logs 1`] = ` Object { "error": Array [], @@ -403,6 +614,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -445,33 +660,35 @@ Object { ` exports[`test/lib/commands/doctor.js TAP error reading directory > readdir error 1`] = ` -Check Value Recommendation/Notes -npm ping ok -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-error-reading-directory/cache (should be owned by current user) -Perms check on local node_modules not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-error-reading-directory/prefix/node_modules (should be owned by current user) -Perms check on global node_modules not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-error-reading-directory/global/lib/node_modules -Perms check on local bin folder not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-error-reading-directory/prefix/node_modules/.bin -Perms check on global bin folder not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-error-reading-directory/global/bin -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  ok   +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-error-reading-directory/global/bin +Perms check on cached files  not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-error-reading-directory/cache (should be owned by current user) +Perms check on local node_modules  not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-error-reading-directory/prefix/node_modules (should be owned by current user) +Perms check on global node_modules not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-error-reading-directory/global/lib/node_modules +Perms check on local bin folder  not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-error-reading-directory/prefix/node_modules/.bin +Perms check on global bin folder  not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-error-reading-directory/global/bin +Verify cache contents  ok  verified 0 tarballs ` exports[`test/lib/commands/doctor.js TAP incorrect owner > incorrect owner 1`] = ` -Check Value Recommendation/Notes -npm ping ok -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache (should be owned by current user) -Perms check on local node_modules ok -Perms check on global node_modules ok -Perms check on local bin folder ok -Perms check on global bin folder ok -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  ok   +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/global/bin +Perms check on cached files  not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-owner/cache (should be owned by current user) +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +Verify cache contents  ok  verified 0 tarballs ` exports[`test/lib/commands/doctor.js TAP incorrect owner > logs 1`] = ` @@ -497,6 +714,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -523,18 +744,19 @@ Object { ` exports[`test/lib/commands/doctor.js TAP incorrect permissions > incorrect owner 1`] = ` -Check Value Recommendation/Notes -npm ping ok -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-permissions/cache (should be owned by current user) -Perms check on local node_modules not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-permissions/prefix/node_modules (should be owned by current user) -Perms check on global node_modules not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-permissions/global/lib/node_modules -Perms check on local bin folder not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-permissions/prefix/node_modules/.bin -Perms check on global bin folder not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-permissions/global/bin -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  ok   +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-permissions/global/bin +Perms check on cached files  not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-permissions/cache (should be owned by current user) +Perms check on local node_modules  not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-permissions/prefix/node_modules (should be owned by current user) +Perms check on global node_modules not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-permissions/global/lib/node_modules +Perms check on local bin folder  not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-permissions/prefix/node_modules/.bin +Perms check on global bin folder  not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-incorrect-permissions/global/bin +Verify cache contents  ok  verified 0 tarballs ` exports[`test/lib/commands/doctor.js TAP incorrect permissions > logs 1`] = ` @@ -581,6 +803,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -624,6 +850,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -649,18 +879,19 @@ Object { ` exports[`test/lib/commands/doctor.js TAP missing git > missing git 1`] = ` -Check Value Recommendation/Notes -npm ping ok -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git not ok Install git and ensure it's in your PATH. -Perms check on cached files ok -Perms check on local node_modules ok -Perms check on global node_modules ok -Perms check on local bin folder ok -Perms check on global bin folder ok -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  ok   +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  not ok Error: Install git and ensure it's in your PATH. +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-missing-git/global/bin +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +Verify cache contents  ok  verified 0 tarballs ` exports[`test/lib/commands/doctor.js TAP missing global directories > logs 1`] = ` @@ -686,6 +917,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -716,18 +951,19 @@ Object { ` exports[`test/lib/commands/doctor.js TAP missing global directories > missing global directories 1`] = ` -Check Value Recommendation/Notes -npm ping ok -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files ok -Perms check on local node_modules ok -Perms check on global node_modules not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-missing-global-directories/global/lib/node_modules -Perms check on local bin folder ok -Perms check on global bin folder not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-missing-global-directories/global/bin -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  ok   +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-missing-global-directories/global/bin +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-missing-global-directories/global/lib/node_modules +Perms check on local bin folder  ok   +Perms check on global bin folder  not ok Check the permissions of files in {CWD}/test/lib/commands/tap-testdir-doctor-missing-global-directories/global/bin +Verify cache contents  ok  verified 0 tarballs ` exports[`test/lib/commands/doctor.js TAP missing local node_modules > logs 1`] = ` @@ -753,6 +989,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -774,18 +1014,19 @@ Object { ` exports[`test/lib/commands/doctor.js TAP missing local node_modules > missing local node_modules 1`] = ` -Check Value Recommendation/Notes -npm ping ok -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files ok -Perms check on local node_modules ok -Perms check on global node_modules ok -Perms check on local bin folder ok -Perms check on global bin folder ok -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  ok   +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-missing-local-node_modules/global/bin +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +Verify cache contents  ok  verified 0 tarballs ` exports[`test/lib/commands/doctor.js TAP node out of date - current > logs 1`] = ` @@ -811,6 +1052,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -832,18 +1077,19 @@ Object { ` exports[`test/lib/commands/doctor.js TAP node out of date - current > node is out of date 1`] = ` -Check Value Recommendation/Notes -npm ping ok -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v not ok Use node v2.0.1 (current: v2.0.0) -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files ok -Perms check on local node_modules ok -Perms check on global node_modules ok -Perms check on local bin folder ok -Perms check on global bin folder ok -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  ok   +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  not ok Use node v2.0.1 (current: v2.0.0) +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-node-out-of-date---current/global/bin +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +Verify cache contents  ok  verified 0 tarballs ` exports[`test/lib/commands/doctor.js TAP node out of date - lts > logs 1`] = ` @@ -869,6 +1115,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -890,18 +1140,19 @@ Object { ` exports[`test/lib/commands/doctor.js TAP node out of date - lts > node is out of date 1`] = ` -Check Value Recommendation/Notes -npm ping ok -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v not ok Use node v1.0.0 (current: v0.0.1) -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files ok -Perms check on local node_modules ok -Perms check on global node_modules ok -Perms check on local bin folder ok -Perms check on global bin folder ok -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  ok   +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  not ok Use node v1.0.0 (current: v0.0.1) +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-node-out-of-date---lts/global/bin +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +Verify cache contents  ok  verified 0 tarballs ` exports[`test/lib/commands/doctor.js TAP non-default registry > logs 1`] = ` @@ -927,6 +1178,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -948,18 +1203,19 @@ Object { ` exports[`test/lib/commands/doctor.js TAP non-default registry > non default registry 1`] = ` -Check Value Recommendation/Notes -npm ping ok -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry not ok Try \`npm config set registry=https://registry.npmjs.org/\` -which git ok /path/to/git -Perms check on cached files ok -Perms check on local node_modules ok -Perms check on global node_modules ok -Perms check on local bin folder ok -Perms check on global bin folder ok -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  ok   +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  not ok Try \`npm config set registry=https://registry.npmjs.org/\` +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-non-default-registry/global/bin +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +Verify cache contents  ok  verified 0 tarballs ` exports[`test/lib/commands/doctor.js TAP npm out of date > logs 1`] = ` @@ -985,6 +1241,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -1006,18 +1266,19 @@ Object { ` exports[`test/lib/commands/doctor.js TAP npm out of date > npm is out of date 1`] = ` -Check Value Recommendation/Notes -npm ping ok -npm -v not ok Use npm v2.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files ok -Perms check on local node_modules ok -Perms check on global node_modules ok -Perms check on local bin folder ok -Perms check on global bin folder ok -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  ok   +npm -v  not ok Use npm v2.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-npm-out-of-date/global/bin +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +Verify cache contents  ok  verified 0 tarballs ` exports[`test/lib/commands/doctor.js TAP ping 404 > logs 1`] = ` @@ -1043,6 +1304,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -1064,18 +1329,19 @@ Object { ` exports[`test/lib/commands/doctor.js TAP ping 404 > ping 404 1`] = ` -Check Value Recommendation/Notes -npm ping not ok 404 404 Not Found - GET https://registry.npmjs.org/-/ping?write=true -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files ok -Perms check on local node_modules ok -Perms check on global node_modules ok -Perms check on local bin folder ok -Perms check on global bin folder ok -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  not ok 404 404 Not Found - GET https://registry.npmjs.org/-/ping?write=true +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-ping-404/global/bin +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +Verify cache contents  ok  verified 0 tarballs ` exports[`test/lib/commands/doctor.js TAP ping 404 in color > logs 1`] = ` @@ -1101,6 +1367,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -1122,18 +1392,19 @@ Object { ` exports[`test/lib/commands/doctor.js TAP ping 404 in color > ping 404 in color 1`] = ` -Check Value Recommendation/Notes -npm ping not ok 404 404 Not Found - GET https://registry.npmjs.org/-/ping?write=true -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files ok -Perms check on local node_modules ok -Perms check on global node_modules ok -Perms check on local bin folder ok -Perms check on global bin folder ok -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  not ok 404 404 Not Found - GET https://registry.npmjs.org/-/ping?write=true +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-ping-404-in-color/global/bin +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +Verify cache contents  ok  verified 0 tarballs ` exports[`test/lib/commands/doctor.js TAP ping exception with code > logs 1`] = ` @@ -1159,6 +1430,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -1180,18 +1455,19 @@ Object { ` exports[`test/lib/commands/doctor.js TAP ping exception with code > ping failure 1`] = ` -Check Value Recommendation/Notes -npm ping not ok request to https://registry.npmjs.org/-/ping?write=true failed, reason: Test Error -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files ok -Perms check on local node_modules ok -Perms check on global node_modules ok -Perms check on local bin folder ok -Perms check on global bin folder ok -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  not ok request to https://registry.npmjs.org/-/ping?write=true failed, reason: Test Error +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-ping-exception-with-code/global/bin +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +Verify cache contents  ok  verified 0 tarballs ` exports[`test/lib/commands/doctor.js TAP ping exception without code > logs 1`] = ` @@ -1217,6 +1493,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -1238,21 +1518,42 @@ Object { ` exports[`test/lib/commands/doctor.js TAP ping exception without code > ping failure 1`] = ` -Check Value Recommendation/Notes -npm ping not ok request to https://registry.npmjs.org/-/ping?write=true failed, reason: Test Error -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Perms check on cached files ok -Perms check on local node_modules ok -Perms check on global node_modules ok -Perms check on local bin folder ok -Perms check on global bin folder ok -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  not ok request to https://registry.npmjs.org/-/ping?write=true failed, reason: Test Error +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH  ok  {CWD}/test/lib/commands/tap-testdir-doctor-ping-exception-without-code/global/bin +Perms check on cached files  ok   +Perms check on local node_modules  ok   +Perms check on global node_modules ok   +Perms check on local bin folder  ok   +Perms check on global bin folder  ok   +Verify cache contents  ok  verified 0 tarballs ` -exports[`test/lib/commands/doctor.js TAP silent > logs 1`] = ` +exports[`test/lib/commands/doctor.js TAP silent errors > logs 1`] = ` +Object { + "error": Array [], + "info": Array [ + Array [ + "Running checkup", + ], + Array [ + "checkPing", + "Pinging registry", + ], + ], + "warn": Array [], +} +` + +exports[`test/lib/commands/doctor.js TAP silent errors > output 1`] = ` + +` + +exports[`test/lib/commands/doctor.js TAP silent success > logs 1`] = ` Object { "error": Array [], "info": Array [ @@ -1275,6 +1576,10 @@ Object { "getGitPath", "Finding git in your PATH", ], + Array [ + "getBinPath", + "Finding npm global bin in your PATH", + ], Array [ "verifyCachedFiles", "Verifying the npm cache", @@ -1295,7 +1600,7 @@ Object { } ` -exports[`test/lib/commands/doctor.js TAP silent > output 1`] = ` +exports[`test/lib/commands/doctor.js TAP silent success > output 1`] = ` ` @@ -1323,19 +1628,8 @@ Object { "Finding git in your PATH", ], Array [ - "verifyCachedFiles", - "Verifying the npm cache", - ], - Array [ - "verifyCachedFiles", - String( - Verification complete. Stats: { - "badContentCount": 0, - "reclaimedCount": 0, - "missingContent": 0, - "verifiedContent": 0 - } - ), + "getBinPath", + "Finding npm global bin in your PATH", ], ], "warn": Array [], @@ -1343,11 +1637,11 @@ Object { ` exports[`test/lib/commands/doctor.js TAP windows skips permissions checks > no permissions checks 1`] = ` -Check Value Recommendation/Notes -npm ping ok -npm -v ok current: v1.0.0, latest: v1.0.0 -node -v ok current: v1.0.0, recommended: v1.0.0 -npm config get registry ok using default registry (https://registry.npmjs.org/) -which git ok /path/to/git -Verify cache contents ok verified 0 tarballs +Check  Value  Recommendation/Notes +npm ping  ok   +npm -v  ok  current: v1.0.0, latest: v1.0.0 +node -v  ok  current: v1.0.0, recommended: v1.0.0 +npm config get registry  ok  using default registry (https://registry.npmjs.org/) +git executable in PATH  ok  /path/to/git +global bin folder in PATH ok  {CWD}/test/lib/commands/tap-testdir-doctor-windows-skips-permissions-checks/global ` diff --git a/tap-snapshots/test/lib/docs.js.test.cjs b/tap-snapshots/test/lib/docs.js.test.cjs index eb516f5e716e6..8038dfa30b6c2 100644 --- a/tap-snapshots/test/lib/docs.js.test.cjs +++ b/tap-snapshots/test/lib/docs.js.test.cjs @@ -2861,7 +2861,7 @@ exports[`test/lib/docs.js TAP usage doctor > must match snapshot 1`] = ` Check your npm environment Usage: -npm doctor +npm doctor [ping] [registry] [versions] [environment] [permissions] [cache] Options: [--registry ] @@ -2869,7 +2869,7 @@ Options: Run "npm help doctor" for more info \`\`\`bash -npm doctor +npm doctor [ping] [registry] [versions] [environment] [permissions] [cache] \`\`\` #### \`registry\` diff --git a/test/lib/commands/doctor.js b/test/lib/commands/doctor.js index eaf2ee6c6f8a2..a4602183e6938 100644 --- a/test/lib/commands/doctor.js +++ b/test/lib/commands/doctor.js @@ -1,5 +1,6 @@ const t = require('tap') const fs = require('fs') +const path = require('path') const { load: loadMockNpm } = require('../../fixtures/mock-npm') const tnock = require('../../fixtures/tnock.js') @@ -52,11 +53,14 @@ const dirs = { }, } -const globals = { - process: { - platform: 'test-not-windows', - version: 'v1.0.0', - }, +const globals = ({ globalPrefix }) => { + return { + process: { + 'env.PATH': `${globalPrefix}:${path.join(globalPrefix, 'bin')}`, + platform: 'test-not-windows', + version: 'v1.0.0', + }, + } } // getuid and getgid do not exist in windows, so we shim them @@ -114,7 +118,7 @@ t.test('all clear in color', async t => { t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') }) -t.test('silent', async t => { +t.test('silent success', async t => { const { joinedOutput, logs, npm } = await loadMockNpm(t, { mocks, globals, @@ -133,6 +137,24 @@ t.test('silent', async t => { t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') }) +t.test('silent errors', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + globals, + config: { + loglevel: 'silent', + }, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(404, '{}') + await t.rejects(npm.exec('doctor', ['ping']), { + message: /Check logs/, + }) + t.matchSnapshot(joinedOutput(), 'output') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') +}) + t.test('ping 404', async t => { const { joinedOutput, logs, npm } = await loadMockNpm(t, { mocks, @@ -144,7 +166,9 @@ t.test('ping 404', async t => { .get('/npm').reply(200, npmManifest(npm.version)) tnock(t, 'https://nodejs.org') .get('/dist/index.json').reply(200, nodeVersions) - await t.rejects(npm.exec('doctor', [])) + await t.rejects(npm.exec('doctor', []), { + message: /See above/, + }) t.matchSnapshot(joinedOutput(), 'ping 404') t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') }) @@ -217,12 +241,16 @@ t.test('npm out of date', async t => { t.test('node out of date - lts', async t => { const { joinedOutput, logs, npm } = await loadMockNpm(t, { mocks, - globals: { - ...globals, - process: { - platform: 'test-not-windows', - version: 'v0.0.1', - }, + globals: (context) => { + const g = globals(context) + return { + ...g, + process: { + ...g.process, + platform: 'test-not-windows', + version: 'v0.0.1', + }, + } }, ...dirs, }) @@ -239,12 +267,15 @@ t.test('node out of date - lts', async t => { t.test('node out of date - current', async t => { const { joinedOutput, logs, npm } = await loadMockNpm(t, { mocks, - globals: { - ...globals, - process: { - ...globals.process, - version: 'v2.0.0', - }, + globals: (context) => { + const g = globals(context) + return { + ...g, + process: { + ...g.process, + version: 'v2.0.0', + }, + } }, ...dirs, }) @@ -299,12 +330,15 @@ t.test('missing git', async t => { t.test('windows skips permissions checks', async t => { const { joinedOutput, logs, npm } = await loadMockNpm(t, { mocks, - globals: { - ...globals, - process: { - ...globals.process, - platform: 'win32', - }, + globals: (context) => { + const g = globals(context) + return { + ...g, + process: { + ...g.process, + platform: 'win32', + }, + } }, prefixDir: {}, globalPrefixDir: {}, @@ -510,3 +544,123 @@ t.test('bad proxy', async t => { t.matchSnapshot(joinedOutput(), 'output') t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') }) + +t.test('discrete checks', t => { + t.test('ping', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + globals, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + await npm.exec('doctor', ['ping']) + t.matchSnapshot(joinedOutput(), 'output') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') + }) + + t.test('versions', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + globals, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/npm').reply(200, npmManifest(npm.version)) + tnock(t, 'https://nodejs.org') + .get('/dist/index.json').reply(200, nodeVersions) + await npm.exec('doctor', ['versions']) + t.matchSnapshot(joinedOutput(), 'output') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') + }) + + t.test('registry', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + globals, + ...dirs, + }) + tnock(t, npm.config.get('registry')) + .get('/-/ping?write=true').reply(200, '{}') + await npm.exec('doctor', ['registry']) + t.matchSnapshot(joinedOutput(), 'output') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') + }) + + t.test('git', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + globals, + ...dirs, + }) + await npm.exec('doctor', ['git']) + t.matchSnapshot(joinedOutput(), 'output') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') + }) + + t.test('permissions - not windows', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + globals, + ...dirs, + }) + await npm.exec('doctor', ['permissions']) + t.matchSnapshot(joinedOutput(), 'output') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') + }) + + t.test('cache', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + globals, + ...dirs, + }) + await npm.exec('doctor', ['cache']) + t.matchSnapshot(joinedOutput(), 'output') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') + }) + + t.test('permissions - windows', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + globals: (context) => { + const g = globals(context) + return { + ...g, + process: { + ...g.process, + platform: 'win32', + }, + } + }, + prefixDir: {}, + globalPrefixDir: {}, + }) + await npm.exec('doctor', ['permissions']) + t.matchSnapshot(joinedOutput(), 'output') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') + }) + + t.test('invalid environment', async t => { + const { joinedOutput, logs, npm } = await loadMockNpm(t, { + mocks, + globals: (context) => { + const g = globals(context) + return { + ...g, + process: { + ...g.process, + 'env.PATH': '/nope', + }, + } + }, + prefixDir: {}, + globalPrefixDir: {}, + }) + await t.rejects(npm.exec('doctor', ['environment'])) + t.matchSnapshot(joinedOutput(), 'output') + t.matchSnapshot({ info: logs.info, warn: logs.warn, error: logs.error }, 'logs') + }) + + t.end() +})