Skip to content

Commit

Permalink
Fix issues on windows with glob and minimatch. Also switch references…
Browse files Browse the repository at this point in the history
… from coffee-script to coffeescript
  • Loading branch information
jb2311 committed Mar 14, 2023
1 parent cbb5669 commit e20dc66
Show file tree
Hide file tree
Showing 7 changed files with 3,552 additions and 4,717 deletions.
5 changes: 4 additions & 1 deletion lib/cli/collect-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ module.exports = ({
try {
const moreSpecFiles = castArray(lookupFiles(arg, extension, recursive))
.filter(filename =>
ignore.every(pattern => !minimatch(filename, pattern))
ignore.every(
pattern =>
!minimatch(filename, pattern, {windowsPathsNoEscape: true})
)
)
.map(filename => path.resolve(filename));
return [...specFiles, ...moreSpecFiles];
Expand Down
9 changes: 7 additions & 2 deletions lib/cli/lookup-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ module.exports = function lookupFiles(

if (!fs.existsSync(filepath)) {
let pattern;
if (glob.hasMagic(filepath)) {
if (glob.hasMagic(filepath, {windowsPathsNoEscape: true})) {
// Handle glob as is without extensions
pattern = filepath;
} else {
Expand All @@ -86,7 +86,12 @@ module.exports = function lookupFiles(
pattern = `${filepath}+(${strExtensions})`;
debug('looking for files using glob pattern: %s', pattern);
}
files.push(...glob.sync(pattern, {nodir: true}));
files.push(
...glob.sync(pattern, {
nodir: true,
windowsPathsNoEscape: true
})
);
if (!files.length) {
throw createNoFilesMatchPatternError(
`Cannot find any files matching pattern "${filepath}"`,
Expand Down
8,242 changes: 3,534 additions & 4,708 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"diff": "5.0.0",
"escape-string-regexp": "4.0.0",
"find-up": "5.0.0",
"glob": "9.2.1",
"glob": "8.1.0",
"he": "1.2.0",
"js-yaml": "4.1.0",
"log-symbols": "4.1.0",
Expand Down Expand Up @@ -97,6 +97,7 @@
"eslint-config-semistandard": "^17.0.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-n": "^15.6.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.0.1",
Expand Down Expand Up @@ -167,7 +168,7 @@
"./lib/nodejs/file-unloader.js": false,
"./lib/nodejs/parallel-buffered-runner.js": false,
"./lib/nodejs/serializer.js": false,
"./lib/nodejs/worker.js": false,
". /lib/nodejs/worker.js": false,
"./lib/nodejs/reporters/parallel-buffered.js": false,
"./lib/cli/index.js": false
},
Expand Down
2 changes: 1 addition & 1 deletion test/integration/compiler-globbing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('globbing like --compilers', function () {
process.execPath +
'" "' +
path.join('bin', 'mocha') +
'" -R json --require coffee-script/register --require test/compiler-fixtures/foo.fixture "test/compiler/*.@(coffee|foo)"',
'" -R json --require coffeescript/register --require test/compiler-fixtures/foo.fixture "test/compiler/*.@(coffee|foo)"',
{cwd: path.join(__dirname, '..', '..')},
function (error, stdout) {
if (error && !stdout) {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/options/compilers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var invokeMocha = helpers.invokeMocha;
describe('--compilers', function () {
it('should report deprecation', function (done) {
invokeMocha(
['--compilers', 'coffee:coffee-script/register'],
['--compilers', 'coffee:coffeescript/register'],
function (err, res) {
if (err) {
return done(err);
Expand Down
4 changes: 2 additions & 2 deletions test/integration/options/extension.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('--extension', function () {
it('should allow comma-separated variables', function (done) {
var args = [
'--require',
'coffee-script/register',
'coffeescript/register',
'--require',
'./test/setup',
'--reporter',
Expand All @@ -32,7 +32,7 @@ describe('--extension', function () {
it('should allow extensions beginning with a dot', function (done) {
var args = [
'--require',
'coffee-script/register',
'coffeescript/register',
'--require',
'./test/setup',
'--reporter',
Expand Down

0 comments on commit e20dc66

Please sign in to comment.