Unexpected parameter(s) error with ${staged} variable
MarkusGnigler opened this issue · 6 comments
Version
v0.5.4
Details
I want format my code with only staged files, so i test the ${staged} variable with an c# script for this.
If i change ${staged}
to some hardcoded values e.g. "arg1"
it works as expected.
When i run husky i got following errors:
Unexpected parameter(s):
<.husky/test.csx>
Husky v0.5.4
USAGE
husky exec <path> [options]
DESCRIPTION
Execute a csharp script (.csx) file
PARAMETERS
* path The script file to execute
-a|--args Arguments to pass to the script Default: .
--no-cache Disable caching Default: "False".
--no-color Disable color output Default: "False".
-v|--verbose Enable verbose output Default: "False".
-h|--help Shows help text.
? Task 'exec-test' failed in 286ms
A simple echo task works fine but every arg to another command won't.
✔️
{
"command": "cmd",
"args": [
"/c",
"echo",
"${staged}"
]
},
❌
{
"name": "Run dotnet format",
"command": "dotnet",
"args": [
"format",
"--files",
"${staged}"
],
"include": [
"**/*.cs"
]
},
Steps to reproduce
- Create c# test script in
.husky/test.csx
to print the args
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Test: {0}", string.Join(",", Args));
return 1;
- Create a task step in
.husky/task-runner.json
{
"tasks": [
{
"name": "exec-test",
"command": "dotnet",
"args": [
"husky",
"exec",
".husky/test.csx",
"--args",
"${staged}"
]
}
]
}
- Run it
dotnet husky run
Hi @MarkusGnigler,
I reproduced your example and it worked as expected. 🤔
are you sure you didn't miss anything in your example?
Thanks for reply.
Strange. I play a little and try with powershell and wsl-debian. It looks like the runner couldn't use the staged variable i guess?
The following command runs fine
dotnet husky exec .husky/test.csx --args arg1 arg2
and dotnet husky run
get a exec error .
Please can you share your task in task-runner.json
, could be that i messed up something there.
It might be related the terminal you are using, can you try PowerShell if you're using something else? it should work for you. I tested on two different machines with two different OS, didn't face this problem
Sorry for the unnecessary disturbance!
I don't know the root causes but seems to be that my company PC is to hard restricted. It work's on my private PC as expected.
Hi @alastair-todd,
Why are you returning 1 if you don't expect an error? any non-zero exit code is considered an error.
in that example I was expecting an error.