From d1ce04cfb3f0cde92f7f612a89b5da6fe851d8e0 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Wed, 16 Oct 2019 10:08:37 -0400 Subject: [PATCH] Use posix paths with patterns passed to globby. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit globby uses the fast-glob package, which states this in its README (RE: patterns): > ⚠️ Always use forward-slashes in glob expressions (patterns and ignore > option). Use backslashes for escaping characters. Previously, we were using `path.join` which will use the OS specific separator and therefore fail to match files when invoked with a directory path directly. --- This also corrects for a bug in globby (to be reported/fixed separately) where the `cwd` option is defaulted to `process.cwd()` _without_ posix correction, and then subsequently an assertion is made that a given path "starts with" the cwd. --- package.json | 1 + src/runner.js | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3f328273..5a1f6755 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "commander": "^3.0.0", "globby": "^10.0.1", "ora": "^4.0.2", + "slash": "^3.0.0", "tmp": "^0.1.0", "workerpool": "^5.0.1" }, diff --git a/src/runner.js b/src/runner.js index 207935a9..e45b3ffe 100644 --- a/src/runner.js +++ b/src/runner.js @@ -1,8 +1,10 @@ const http = require('http'); const https = require('https'); const { writeFileSync } = require('fs'); -const { resolve, extname, join } = require('path'); +const { join } = require('path').posix; +const { resolve, extname } = require('path'); const colors = require('colors/safe'); +const slash = require('slash'); const globby = require('globby'); const ora = require('ora'); const queue = require('async-promise-queue'); @@ -182,7 +184,14 @@ async function getAllFiles(paths) { return path; }); - const files = await globby(patterns, { absolute: true, gitignore: true }); + const files = await globby(patterns, { + // must specify a properly escaped `cwd` because globby infers from + // process.cwd() directly and without correcting back to posix paths + // asserts if the individual file path isn't "in" the cwd + cwd: slash(process.cwd()), + absolute: true, + gitignore: true, + }); if (files.length < 1) { throw new NoFilesError(); }