Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept a String Argument to --shell #993

Closed
Kurt-von-Laven opened this issue Jul 20, 2021 · 2 comments · Fixed by #994
Closed

Accept a String Argument to --shell #993

Kurt-von-Laven opened this issue Jul 20, 2021 · 2 comments · Fixed by #994

Comments

@Kurt-von-Laven
Copy link
Contributor

Kurt-von-Laven commented Jul 20, 2021

Description

Execute commands in the shell lint-staged is run in when the --shell option is passed. Lint-staged uses execa, which also accepts a --shell option: "If true, runs file inside of a shell. Uses /bin/sh on UNIX and cmd.exe on Windows. A different shell can be specified as a string." ~ https://github.com/sindresorhus/execa#shell

Since lint-staged ferries the --shell option through to execa, it would be ideal for it to also accept a string specifying a custom shell. This would allow lint-staged configs requiring the --shell option to function consistently on Unix and Windows development environments. N.B. Windows ships with Bash these days. An alternative solution would be to run lint-staged commands in the shell from which lint-staged was executed when --shell is passed. That would be more intuitive from the perspective of the developer committing code but perhaps less intuitive from the perspective of the developer authoring the lint-staged config.

Steps to reproduce

  1. Run lint-staged (e.g., by committing in a repository with lint-staged configured) from Bash on Windows.
  2. The lint-staged commands are run in Command Prompt.

Environment

  • OS: Windows 10
  • Node.js: v16.14.0
  • lint-staged: v11.0.0
@okonet
Copy link
Collaborator

okonet commented Jul 20, 2021

This sounds like a great candidate for a PR!

@iiroj
Copy link
Member

iiroj commented Jul 20, 2021

Seems straightforward enough, I will try to make a quick PR.

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

Successfully merging a pull request may close this issue.

3 participants