Request: Lenient shell command parser
See original GitHub issueDescription
It’d be great if normal bash command modifiers could be accepted (see below for example). I know same can be accomplished with an external script or an npm script – but a one-liner would be super useful and less clutter.
Steps to reproduce
This example will fail the hook if there are any lingering .only()
s left in staged test files. The !
is used to negate the exit code of grep.
"lint-staged": {
"src/**/*.test.js": [
"!grep -q '\\.only\\W' "
]
}
Debug Logs
...
Running tasks for src/**/*.test.js [started]
lint-staged:make-cmd-tasks Creating listr tasks for commands [ "!grep -q '\\.only\\W' " ] +0ms
lint-staged:find-bin Resolving binary for command `!grep -q '\.only\W' ` +349ms
Running tasks for src/**/*.test.js [failed]
→ !grep could not be found. Try `npm install !grep`.
Running linters... [failed]
!grep could not be found. Try `npm install !grep`.
This and not being able to position the file in the command, (e.g. grep -q '\.only\W' {}; test $? -eq 1
where {}
is the (supposed!) file placeholder), is a real handicap in this otherwise very useful tool, IMHO.
Environment
- OS: macOS High Sierra
- Node.js: v11.13.0
lint-staged
: v8.2.1
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Simple shell script parser - metacpan.org
This module implements a rudimentary shell script parser in Perl. It was primarily written as a backend for Syntax::Highlight::Shell , in order to...
Read more >16 Parsing command line arguments with util.parseArgs()
The following steps are involved in processing command line arguments: The user inputs a text string. The shell parses the string into a...
Read more >Parsing Command Line Arguments in C++? - Stack Overflow
I understand the use of this library in C code, but IMO, this is way too low level to be acceptable in any...
Read more >jc | CLI tool and python library that converts the output of ...
Argument Command or Filetype Documentation
‑‑acpi acpi command parser details
‑‑airport airport ‑I command parser details
‑‑airport‑s airport ‑s command parser details
Read more >picocli - a mighty tiny command line interface
Lenient Mode. From picocli 3.2, the parser can be configured to continue parsing invalid input to the end. When collectErrors is set to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@iiroj Yes that worked – I don’t know how, but it did. Brilliant solution to both complex commands and filename placeholder!
Output:
Removing the
!
is successful. Compound commands also works:Not so simple with
!
after all - obviously it also negates exit code 0. Had to convert tolint-staged.config.js
and build my own command-line: