Skip to content

Commit

Permalink
Using the standalone "zeptomatch-escape" utility
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiospampinato committed Apr 13, 2024
1 parent c342780 commit d002ea8
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 9 deletions.
61 changes: 54 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"tiny-readdir-glob": "^1.22.24",
"tiny-spinner": "^2.0.3",
"worktank": "^2.6.1",
"zeptomatch": "^1.2.2"
"zeptomatch": "^2.0.0",
"zeptomatch-escape": "^1.0.0"
},
"devDependencies": {
"@types/js-yaml": "^4.0.9",
Expand Down
4 changes: 3 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import url from "node:url";
import { exit } from "specialist";
import readdir from "tiny-readdir-glob";
import zeptomatch from "zeptomatch";
import zeptomatchEscape from "zeptomatch-escape";
import type { ContextOptions, FormatOptions, FunctionMaybe, Key, LogLevel, Options, PrettierConfigWithOverrides, PrettierPlugin } from "./types.js";
import type { PluginsOptions, PromiseMaybe } from "./types.js";

Expand Down Expand Up @@ -284,7 +285,8 @@ function normalizeOptions(options: unknown, targets: unknown[]): Options {
if (!isObject(options)) exit("Invalid options object");

const targetsGlobs = targets.filter(isString);
const targetsStatic = "--" in options && Array.isArray(options["--"]) ? options["--"].filter(isString).map(zeptomatch.escape) : [];

const targetsStatic = "--" in options && Array.isArray(options["--"]) ? options["--"].filter(isString).map(zeptomatchEscape) : [];
const globs = [...targetsGlobs, ...targetsStatic];

if (!globs.length) exit("Expected at least one target file/dir/glob");
Expand Down

0 comments on commit d002ea8

Please sign in to comment.