Do not pass args into command
See original GitHub issueHi, is there any possibility to not pass any arguments into command. I’m using lint-staged like so:
...
"scripts": {
"build": "gulp build"
},
"lint-staged": {
"resources/assets/client/js/application/**/*.js": [
"npm run build",
"eslint --fix",
"git add"
]
}
...
So I dont want to pass files args into my build task because it breaks.
npm run build -- file1.ext file2.ext
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:12 (4 by maintainers)
Top Results From Across the Web
Parameters / Arguments - Windows CMD - SS64.com
How-to: Pass Command Line arguments (Parameters) to a Windows batch file. ... You can get the value of any argument using a %...
Read more >How to pass arguments to a Button command in Tkinter?
This doesn't work if someNumber is in fact a variable that changes values inside a loop that creates many buttons. Then each button...
Read more >How to pass arguments on the command line using bash script
The command -line argument is a parameter that we can pass to our Bash script during the execution ... Your browser can '...
Read more >Passing Arguments to the Script - Free Interactive Shell Tutorial
Arguments can be passed to the script when it is executed, by writing them as a space-delimited list following the script file name....
Read more >How to pass command line arguments to bash script when ...
You can't pass arguments to an at job really ( at -f job.sh argument ... would not work), so you must make the...
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
You can very simply ignore args. For example:
The trailing
:
is the “no-op” command in Bash. Any args passed to it are always ignored, and it always exits0
.For example, to use it in lint-staged:
that way for example lint-staged will not break the TypeScript
tsc
command (because passing it files changes the meaning, and in TypeScript you want it to check your whole project otherwise TypeScript won’t detect type errors in files that you didn’t modify in your commit, thus you will introduce errors into your commit).Also because of the
&&
, if thetsc
command fails, then the whole command will fail and the commit will fail (which is what you want).@trusktr,
Did you test this example? I tried it and it didn’t do the thing.
I followed through
lint-staged
source code and it seems like this example should not work.lint-staged
does not look at the command as at bash script. Instead, it thinks of it as a single binary with an array of arguments, sotsc -p ./tsconfig.json --noEmit && :
translates into, roughly speaking,execFile('tsc', ['-p', './tsconfig.json', '--noEmit', '&&', ':'])
. So,&&
and:
are just two another args oftsc
command and are just ignored.It seems like, if you want to ignore staged files as args in case of
tsc
command, you should use it like this:Am I missing something?