From b6df0913ca73246f1fa6cfa0e81e34ba5f2b6204 Mon Sep 17 00:00:00 2001 From: Olivier Chevet Date: Mon, 5 Aug 2019 05:59:12 +0200 Subject: [PATCH] test: Proper handing of /usr/bin/node lifecycle-path test PR-URL: https://github.com/npm/cli/pull/228 Credit: @olivr70 Close: #228 Reviewed-by: @isaacs --- test/broken-under-nyc-and-travis/lifecycle-path.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/broken-under-nyc-and-travis/lifecycle-path.js b/test/broken-under-nyc-and-travis/lifecycle-path.js index 6209319b412f6..0cfa5d3d62c5e 100644 --- a/test/broken-under-nyc-and-travis/lifecycle-path.js +++ b/test/broken-under-nyc-and-travis/lifecycle-path.js @@ -4,6 +4,7 @@ var path = require('path') var mkdirp = require('mkdirp') var osenv = require('osenv') var rimraf = require('rimraf') +var which = require('which') var test = require('tap').test var common = require('../common-tap.js') @@ -21,6 +22,9 @@ if (isWindows) { PATH = '/bin:/usr/bin' } +var systemNode = which.sync('node', { nothrow: true, path: PATH }) +// the path to the system wide node (null if none) + test('setup', function (t) { cleanup() mkdirp.sync(pkg) @@ -183,6 +187,12 @@ function checkPath (testconfig, t) { 'The node binary used for scripts is.*' + process.execPath.replace(/[/\\]/g, '.')) t.match(stderr, regex, 'reports the current binary vs conflicting') + } else if (systemNode !== null) { + var regexSystemNode = new RegExp( + 'The node binary used for scripts is.*' + + systemNode.replace(/[/\\]/g, '.') + ) + t.match(stderr, regexSystemNode, 'reports the system binary vs conflicting') } else { t.match(stderr, /there is no node binary in the current PATH/, 'informs user that there is no node binary in PATH') }