question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected parameter(s) error with ${staged} variable

See original GitHub issue

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

  1. 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;
  1. Create a task step in .husky/task-runner.json
{
  "tasks": [
    {
      "name": "exec-test",
      "command": "dotnet",
      "args": [
        "husky",
        "exec",
        ".husky/test.csx",
        "--args",
        "${staged}"
      ]
    }
  ]
}
  1. Run it
dotnet husky run

Issue Analytics

  • State:closed
  • Created 4 months ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
MarkusGniglercommented, Jun 5, 2023

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.

0reactions
alirezanetcommented, Jun 5, 2023

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Pipelines YAML: Unexpected value 'variables' and ...
The jobs element doesn't support variables , job/stage support it instead. Moving the variables to correct scope would resolve this issue.
Read more >
unexpected value stages/variables error?? · Issue #12380
Hello, I have been figuring out this error for days but not sure why. I want to set up a global variable that...
Read more >
Can you not have parameters and variables in the same ...
Hi, according to this GitHub issue, it seems that we can't use parameters and variables in the same template. You can define variable...
Read more >
Setting output variable when multiple stages share a job ...
Setting output variable when multiple stages share a job results in unexpected sharing - Developer Community.
Read more >
Variable groups in azure pipeline templates don't work
I have a sample template pipeline like the below. parameters: npmPublishFeed: "test" variables: - group: "AzureDevopsAccessToken" stages: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found