From 34776b266a4706dd6d97d94fbdfbf52548fde026 Mon Sep 17 00:00:00 2001 From: dangreen Date: Tue, 1 Sep 2026 17:12:28 +0400 Subject: [PATCH] fix(cli): keep a brace glob of `--match` in one piece The option reader split every value by commas, so `-m "**/*.{jpg,png}"` became two patterns that both had to match: nothing matched, and the run wrote nothing while exiting 0. A comma separated media query list broke the same way, into two queries joined by and instead of one list. `--match` now takes the argument as it is and collects the repeated options, so several patterns are passed as repeated `-m`. `--width` and `--format` keep the comma form. --- packages/cli/package.json | 2 +- packages/cli/src/args.spec.ts | 16 ++++++++++++++++ packages/cli/src/args.ts | 4 ++-- pnpm-lock.yaml | 10 ++++++++-- pnpm-workspace.yaml | 1 + 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index e270b8a..9c508eb 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -57,7 +57,7 @@ "dependencies": { "@srcset/bundler-utils": "workspace:^", "@srcset/core": "workspace:^", - "argue-cli": "^3.1.0", + "argue-cli": "^3.2.0", "tinyglobby": "^0.2.10" }, "devDependencies": { diff --git a/packages/cli/src/args.spec.ts b/packages/cli/src/args.spec.ts index e732457..e05ff25 100644 --- a/packages/cli/src/args.spec.ts +++ b/packages/cli/src/args.spec.ts @@ -56,6 +56,22 @@ describe('cli', () => { }) }) + it('should keep a brace glob of the match option in one piece', () => { + setArgs('-m', '**/*.{jpg,png}') + + expect(parseCliArgs().rule).toEqual({ + match: ['**/*.{jpg,png}'] + }) + }) + + it('should collect the repeated match options', () => { + setArgs('-m', '**/*.jpg', '-m', '(min-width: 1000px)') + + expect(parseCliArgs().rule).toEqual({ + match: ['**/*.jpg', '(min-width: 1000px)'] + }) + }) + it('should support camelCase twins and negation', () => { setArgs('--skipOptimization', '--no-scalingUp') diff --git a/packages/cli/src/args.ts b/packages/cli/src/args.ts index 88427b5..62304c9 100644 --- a/packages/cli/src/args.ts +++ b/packages/cli/src/args.ts @@ -16,7 +16,7 @@ export const usage = `srcset [...sources] [...options] sources Source image(s) glob patterns. --help, -h Print this message. --verbose, -v Print processed images. - --match, -m Glob pattern(s) or media query(ies) to match images by name or size. Multiple values must all match. + --match, -m Glob pattern or media query to match images by name or size. Repeat to add more - all of them must match. --width, -w Output image(s) widths to resize, value less than or equal to 1 is treated as a multiplier. --format, -f Output image(s) formats to convert. --skip-optimization Do not optimize output images. @@ -60,7 +60,7 @@ export function parseCliArgs(): CliArgs { } = readOptions( flag(alias('help', 'h')), flag(alias('verbose', 'v')), - option(alias('match', 'm'), Array), + option(alias('match', 'm'), [String]), option(alias('width', 'w'), Array), option(alias('format', 'f'), Array), flag(autocase('skipOptimization')), diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 41b96c3..4370256 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -187,8 +187,8 @@ importers: specifier: workspace:^ version: link:../core argue-cli: - specifier: ^3.1.0 - version: 3.1.0 + specifier: ^3.2.0 + version: 3.2.0 tinyglobby: specifier: ^0.2.10 version: 0.2.17 @@ -2169,6 +2169,10 @@ packages: resolution: {integrity: sha512-DhBpBfXL4SS2uC0N922MMajKR3CdrTG0u2or1PNYgXMsrSzViJrbtvT0nCLlLGUI0plam/ZZCs7aAauHtW9thw==} engines: {node: '>=22'} + argue-cli@3.2.0: + resolution: {integrity: sha512-VipTB0gXgGIFO2Rg9yEVN5wLt2AurJcZqDbgmYSwPwsykhLrQhs240/bfceev4w68lI8JshoOJIk9uW7tFzROw==} + engines: {node: '>=22'} + aria-query@5.1.3: resolution: {integrity: sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==} @@ -6080,6 +6084,8 @@ snapshots: argue-cli@3.1.0: {} + argue-cli@3.2.0: {} + aria-query@5.1.3: dependencies: deep-equal: 2.2.3 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 8240d38..296a8e4 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -24,6 +24,7 @@ minimumReleaseAgeExclude: - '@oxlint-tsgolint/win32-arm64@0.25.0' - '@oxlint-tsgolint/win32-x64@0.25.0' - oxlint-tsgolint@0.25.0 + - argue-cli@3.2.0 packageExtensions: '@sveltejs/package': dependencies: