diff --git a/lib/npa.js b/lib/npa.js index 50121b9..a25c0a5 100644 --- a/lib/npa.js +++ b/lib/npa.js @@ -66,8 +66,6 @@ function isFileSpec (spec) { if (isWindows) { return isWindowsFile.test(spec) } - // We never hit this in windows tests, obviously - /* istanbul ignore next */ return isPosixFile.test(spec) } diff --git a/package.json b/package.json index 2d8f91d..908ee39 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ "node": "^20.17.0 || >=22.9.0" }, "tap": { - "branches": 97, "nyc-arg": [ "--exclude", "tap-snapshots/**" diff --git a/test/posix.js b/test/posix.js new file mode 100644 index 0000000..9b453ce --- /dev/null +++ b/test/posix.js @@ -0,0 +1,26 @@ +// redefine process.platform before any requires so that we don't cache a require that got the non-redefined value +const { platform } = process +Object.defineProperty(process, 'platform', { value: 'linux' }) + +const t = require('tap') +const npa = require('..') + +t.teardown(() => { + Object.defineProperty(process, 'platform', { value: platform }) +}) + +// These are purely for coverage +// We need tests that act like linux so that code paths are covered both ways when testing in windows itself. +// +t.test('file spec', t => { + const actual = npa('./local') + t.equal(actual.type, 'directory') + t.equal(actual.raw, './local') + t.end() +}) + +t.test('encoded path', t => { + const actual = npa('./path\\backslash') + t.equal(actual.rawSpec, './path\\backslash') + t.end() +})