sindresorhus / globby

User-friendly glob matching
MIT License
2.49k stars 126 forks source link

ignore is broken when it is not array (regression) #262

Closed alexander-akait closed 6 months ago

alexander-akait commented 6 months ago

Code:

import url from "url";
import path from "path";
import { globby } from "globby";

console.log(
  await globby("**/*", {
    followSymbolicLinks: true,
    ignore: "**/index.ejs",
    cwd: path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "public"),
    objectMode: true,
  }),
);

Output:

TypeError: directoryPaths.map is not a function

Can be fixed using ignore: ["**/index.ejs"], i.e. as array

sindresorhus commented 6 months ago

ignore is documented to accept an array, so you are using it incorrectly.

https://github.com/mrmlnc/fast-glob#ignore

alexander-akait commented 6 months ago

@sindresorhus It works correctly before, for example in v13, and fast-glob supports string and array of strings, but it was not documented, directoryPaths.map is not a function inside globby, because it can return string

mrmlnc commented 6 months ago

JFYI: https://github.com/mrmlnc/fast-glob/releases/tag/3.3.1

sindresorhus commented 6 months ago

but it was not documented

There are no guarantees when using undocumented behavior.

sindresorhus commented 6 months ago

I'm not a big fan of accepting both a string and string[] in general. It's better to make it simple and always do string[] when multiple values are accepted.

sindresorhus commented 6 months ago

I'm happy to accept a PR to improve the error message when a string is accidentally passed though.