Skip to content

fix: preserve equals signs in CLI variable values - #4575

Open
wozhenbang2004 wants to merge 2 commits into
less:masterfrom
wozhenbang2004:fix/cli-variable-equals-3388
Open

wozhenbang2004 wants to merge 2 commits into
less:masterfrom
wozhenbang2004:fix/cli-variable-equals-3388

Conversation

@wozhenbang2004

@wozhenbang2004 wozhenbang2004 commented Nov 20, 2026 •

Copy link
Copy Markdown

What:

Split CLI variable assignments at the first separator so --modify-var and --global-var retain the complete value. Adds CLI coverage for attribute selectors, multiple equals signs, variable precedence, ordinary values and empty strings.

Why:

lessc --modify-var="shell_selector='html[theme=dark]'" truncates the value at the second = and fails to compile. This addresses the variable-value truncation in #3388.

pnpm test:node and lint pass on Node 24. The browser portion of pnpm test could not run because the Playwright browser executable is unavailable.

Checklist:

  • Documentation — N/A, existing variable syntax is unchanged
  • Added/updated unit tests
  • Code complete

Summary by CodeRabbit

  • Bug Fixes
    • Fixed command-line variable parsing so values retain any additional = characters.
    • Options without an = are now handled correctly, and empty values remain supported.
    • Variable overrides now produce the expected CSS, including when source declarations take precedence.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The lessc variable option parser now splits at the first = and handles options without one. The test harness adds six CLI cases that check exit status and exact CSS output.

Changes: CLI variable option parsing and tests

Layer / File(s) Summary
Parse and test CLI variable options
packages/less/bin/lessc, packages/less/test/less-test.js, packages/less/test/index.js
The parser preserves additional = characters in values and uses the full option as the name when no = is present. Six CLI cases check variable option outputs and exit status.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: matthew-dean

Merge Risk: Minimal · up to eb369

Variable values that contain equals signs, such as attribute selectors passed to --modify-var, are now preserved. The change is narrow, comes with tests, and is easy to revert, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix: preserve equals signs in CLI variable values" matches the main change. The summary shows parseVariableOption now splits at the first '=' so values with later '=' characters (for exampl…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix: preserve equals signs in CLI variable values" matches the main change. The summary shows parseVariableOption now splits at the first '=' so values with later '=' characters (for example attribute selectors such as html[theme=dark]) are kept intact for --modify-var and --global-var. The added testCliVariableOptions tests cover the same behavior, so the title is specific and accurate.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/less/test/index.js

Oops! Something went wrong! :(

ESLint: 7.32.0

TypeError: Failed to load plugin '@typescript-eslint' declared in 'packages/less/.eslintrc.cjs#overrides[0]': Cannot read properties of undefined (reading 'Undefined')
Referenced from: /packages/less/.eslintrc.cjs
at Object. (/.eslint-tmp/node_modules/.pnpm/@typescript-eslint+eslint-plugin@4.33.0_@typescript-eslint[email protected][email protected]__ca4ca277770b9683d36ba7fd429d0937/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-unnecessary-condition.js:36:34)
at Module._compile (/.eslint-tmp/node_modules/.pnpm/[email protected]/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object..js (node:internal/modules/cjs/loader:2060:10)
at Module.load (node:internal/modules/cjs/loader:1651:32)
at Module.load (node:internal/modules/cjs/loader:1443:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:261:19)
at Module.require (node:internal/modules/cjs/loader:1674:12)
at require (/.eslint-tmp/node_modules/.pnpm/[email protected]/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at Object. (/.eslint-tmp/node_modules/.pnpm/@typescript-eslint[email protected]
@typescript-eslint[email protected][email protected]__ca4ca277770b9683d36ba7fd429d0937/node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js:74:52)
at Module._compile (/.eslint-tmp/node_modules/.pnpm/[email protected]/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)

packages/less/test/less-test.js

ESLint skipped: the matched ESLint configuration already failed (plugin-compatibility).

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7133316 and eb3699c.

Files selected for processing: 3

  • packages/less/bin/lessc
  • packages/less/test/index.js
  • packages/less/test/less-test.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@greptile-apps

greptile-apps Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Fixes CLI variable values that contain additional equals signs.

  • lessc keeps equals signs inside command-line variable values.

No actionable issues found. Tests were not run during this review.

Reviews (2) · Last reviewed commit: "Cover CLI variable values and existing p..." · Reviewed by Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant