ruyadorno / ntl

Node Task List: Interactive cli to list and run package.json scripts
https://www.npmjs.com/package/ntl
MIT License
932 stars 35 forks source link

Indenting Despite --descriptions-only or exclude tasks #71

Open entozoon opened 3 years ago

entozoon commented 3 years ago
{
  "scripts": {
    "foo": "foo",
    "bar baz qux quux quuz": "bar"
  },
  "ntl": {
    "descriptions": {
      "foo": "Lorem ipsum"
    }
  }
}

Even with using the descriptions only option, it still indents the script name as if those other option(s) were listed:

$ npx ntl
? Select a task to run: (Use arrow keys)
❯                   foo › Lorem ipsum 
  bar baz qux quux quuz ›  

$ npx ntl -o   
? Select a task to run: (Use arrow keys)
❯                   foo › Lorem ipsum 

Why does it matter? If you have the situation where you only want to show scripts that have descriptions, but then some of the hidden script names are really long

Same thing occurs if you exclude a task with the -e exclude task arg

MangelMaxime commented 3 years ago

The same is true if there are pre or post tasks.

With only a release task.

> release › Run the tests and release a new version of the differents packages if needed

With a prerelease and release tasks.

>    release › Run the tests and release a new version of the different packages if needed

The problem seems to be that getLongName doesn't apply the different filters as they are applied when constructing the input list only.

https://github.com/ruyadorno/ntl/blob/7f4126c3a2f6cc77fc36c6e3a93af14122ce22df/cli.js#L219-L220