Closed Bug 1829162 Opened 1 year ago Closed 1 year ago

Prettier not running on Windows when passing a path to eslint

Categories

(Developer Infrastructure :: Lint and Formatting, defect)

defect

Tracking

(firefox114 fixed)

RESOLVED FIXED
Tracking Status
firefox114 --- fixed

People

(Reporter: mkaply, Assigned: standard8)

References

Details

Attachments

(1 file)

If I pass a path to eslint, get:

An error occurred running prettier. Please check the following error messages:

'js' is not recognized as an internal or external command,
operable program or batch file.

It looks like we need quotes around the -lists-different command

Type: task → defect

The problem appears to be here: https://searchfox.org/mozilla-central/rev/31f5847a4494b3646edabbdd7ea39cb88509afe2/tools/lint/eslint/__init__.py#117-119

We tried adding quotes around each pattern, and that fixed it on Windows, but broke it on Mac.

Andrew, do you have any ideas about this? Should we add quotes only for Windows?

Flags: needinfo?(ahal)

The reason it works for one but not the other is because later on in the file you set shell=True for Windows only:
https://searchfox.org/mozilla-central/rev/31f5847a4494b3646edabbdd7ea39cb88509afe2/tools/lint/eslint/__init__.py#221

So yeah, you'll basically need to shell quote on Windows, but not anywhere else (or find a way to keep shell=False on Windows). There's a built-in function, but unfortunately it's not safe to use on non-POSIX compliant shells.. There are also 3rd party libraries for shell quoting on Windows, but your simple fix here is probably preferable to pulling in a new dependency.

Flags: needinfo?(ahal)
Assignee: nobody → standard8
Status: NEW → ASSIGNED
Pushed by mbanner@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ebde9bbce2c4 When passing paths to Prettier, ensure they are quoted when running on Windows. r=ahal
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
See Also: → 1834118
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: