+24
-2
@@ -24,2 +24,4 @@ #!/usr/bin/env node | ||
| 'no-ignore-selectors-defaults': { type: 'boolean', short: 'n', default: false }, | ||
| 'exit-zero': { type: 'boolean', short: 'z', default: false }, | ||
| 'no-exit-zero': { type: 'boolean', short: 'e', default: false }, | ||
| config: { type: 'string', short: 'c' }, | ||
@@ -66,2 +68,4 @@ help: { type: 'boolean', short: 'h', default: false }, | ||
| -n, --no-ignore-selectors-defaults Disable the built-in selector hack ignore list (vendor-prefixed pseudo-elements, IE hacks) | ||
| -z, --exit-zero Exit with status 0 even when findings are skipped as unsafe to auto-merge or withheld by \`--savings-only\`; a file that fails to read or parse still exits 1 | ||
| -e, --no-exit-zero Override \`exitZero: true\` from a config file for the respective run | ||
| -c, --config <path> Path to a config file (defaults to \`css-dedup.config.js\` in the working directory, if present) | ||
@@ -1047,4 +1051,18 @@ -h, --help Show this help`); | ||
| ]; | ||
| // `--no-exit-zero` wins over a project’s own `exitZero: true`, the same | ||
| // way `--no-ignore-selectors-defaults` wins over that config default—both | ||
| // exist to force a config-set default back off for one run | ||
| const exitZero = values['no-exit-zero'] ? false : values['exit-zero'] || (config.exitZero ?? false); | ||
| const { files, discovered } = await expandTargets(positionals, ignorePathPatterns); | ||
| // `stat()`/`readdir()` inside `expandTargets` aren’t wrapped there, so a | ||
| // missing path or an unreadable directory would otherwise surface as a | ||
| // raw stack trace via the top-level `catch` below instead of the same | ||
| // clean, styled message every other resolution error on this page gets | ||
| let files, discovered; | ||
| try { | ||
| ({ files, discovered } = await expandTargets(positionals, ignorePathPatterns)); | ||
| } catch (err) { | ||
| console.error(styleText('red', `Could not resolve ${positionals.join(', ')}: ${err.message}`)); | ||
| process.exit(1); | ||
| } | ||
| if (!files.length) { | ||
@@ -1069,3 +1087,7 @@ if (discovered > 0) { | ||
| const result = await processTarget(file, options, { multi }, prefetched[index]); | ||
| if (result.exitFailure) failed = true; | ||
| // `--exit-zero` never changes what got merged—only what a finding | ||
| // (skipped as unsafe, or withheld by `--savings-only`) does to the exit | ||
| // code. A file that couldn't be read or parsed is a real failure, and | ||
| // stays one regardless of the flag. | ||
| if (result.exitFailure && !(exitZero && !result.errored)) failed = true; | ||
| results.push(result); | ||
@@ -1072,0 +1094,0 @@ } |
+1
-1
@@ -64,3 +64,3 @@ { | ||
| "types": "src/index.d.ts", | ||
| "version": "1.5.0" | ||
| "version": "1.6.0" | ||
| } |
+7
-2
@@ -81,2 +81,4 @@ # CSS Dedup, the CSS Declaration Deduplicator | ||
| | `--ignore-path <pattern>`, `-p` | Regular expression tested against each file’s path, relative to the working directory; a match excludes the file (repeatable) | | ||
| | `--exit-zero`, `-z` | Exit with status 0 even when findings are skipped as unsafe to auto-merge or withheld by `--savings-only`; a file that fails to read or parse still exits 1 | | ||
| | `--no-exit-zero`, `-e` | Override `exitZero: true` from a config file for the respective run | | ||
| | `--config <path>`, `-c <path>` | Path to a config file (defaults to `css-dedup.config.js` in the working directory, if present) | | ||
@@ -89,2 +91,4 @@ | `--help`, `-h` | Show usage information | | ||
| CSS Dedup only ever merges what it can prove safe: A duplicate group flagged unsafe to auto-merge is never merged, `--exit-zero` or not, and the finding still prints exactly the same either way—nothing about the flag changes what gets analyzed or reported, only what happens to the exit code. That’s for a build step that must otherwise succeed (e.g., a minification pipeline gating CI): `--fix` should not produce anything wrong (that would be a bug), so failing the build over a finding it just left on record for later is a separate call from whether the CSS itself is fine. Exit `1` still applies to a file that couldn’t be read or parsed. | ||
| A file that fails to parse—invalid CSS, or a non-standard dialect PostCSS doesn’t accept—doesn’t stop the run: Its error is reported and CSS Dedup moves on to the rest. | ||
@@ -107,7 +111,8 @@ | ||
| ignoreSelectorsDefaults: true, // set to `false` to disable the built-in hack list | ||
| ignorePaths: [] // file paths to exclude, matched relative to the working directory, e.g., `[/dist\//]` | ||
| ignorePaths: [], // file paths to exclude, matched relative to the working directory, e.g., `[/dist\//]` | ||
| exitZero: false // set to `true` to exit 0 regardless of findings still on record | ||
| }; | ||
| ``` | ||
| CLI flags layer on top of the config file rather than replacing it: `--ignore-selector` patterns are added to `ignoreSelectors` from the config, `--ignore-path` patterns are added to `ignorePaths`, and `--no-ignore-selectors-defaults` always wins over `ignoreSelectorsDefaults: true` in the config. `aggressive` and `savingsOnly` are consolidation policies, so they only take effect on `--fix` runs, deciding what gets merged and whether the file is written. | ||
| CLI flags layer on top of the config file rather than replacing it: `--ignore-selector` patterns are added to `ignoreSelectors` from the config, `--ignore-path` patterns are added to `ignorePaths`, and `--no-ignore-selectors-defaults` always wins over `ignoreSelectorsDefaults: true` in the config. `aggressive` and `savingsOnly` are consolidation policies, so they only take effect on `--fix` runs, deciding what gets merged and whether the file is written. `exitZero` applies regardless of `--fix`, since report mode’s exit code signals the same thing `--fix` mode’s does—findings still on record, nothing merged; `--no-exit-zero` always wins over `exitZero: true` in the config, the same way `--no-ignore-selectors-defaults` wins over its own default. | ||
@@ -114,0 +119,0 @@ ### Programmatic Use |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
196837
1.47%3197
0.69%248
2.06%