Skip to content

Commit

Permalink
feat: support stop dot at the end (#36)
Browse files Browse the repository at this point in the history
Sometimes you want to match a script with one word, but there are multiple two and three word scripts matching the prefix.

```json
{
  "scripts": {
    "cypress": "cypress -help",
    "cypress:open": "cypress open",
    "cypress:run": "cypress run",
    "cypress:run:record": "cypress run --record"
  }
}
```

In order to run "cypress" script use prefix with "." at the end:

```
# same as "npm run cypress"
$ nr c. # only finds single word starting with "c"

# same as "npm run cypress:open"
$ nr c-o.

# same as "npm run cypress:run"
$ nr c-r.
```
  • Loading branch information
bahmutov authored Mar 11, 2021
1 parent 525f601 commit 2853e10
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ jobs:
# use prefix search by word
node bin/npm-quick-run.js t-f 'foo bar'
node bin/npm-quick-run.js t:f 'foo bar'
# with stopper . at the end
# https://github.com/bahmutov/npm-quick-run/issues/35
node bin/npm-quick-run.js t-f. 'foo bar'
# should find single "size" script
node bin/npm-quick-run.js s.
- name: Semantic Release 🚀
uses: cycjimmy/semantic-release-action@v2
Expand Down
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Install as a global tool `npm install -g npm-quick-run`. This creates two aliase
$ nr t # runs script starting with "t"
$ nr m -w # runs a script starting with "m", probably "npm run mocha -- -w"
$ nr -i # runs npm-quick-run in interactive mode
$ nr c-r # find script that has two+ words
# first starts with "c", second with "r"
$ nr c-r. # find script with exactly two words
# first starts with "c", second with "r"

## Demo

Expand Down Expand Up @@ -82,6 +86,34 @@ nr c-r-r
# executes "cypress:run:record"
```

### Separate words with count

Sometimes you want to match a script with one word, but there are multiple two and three word scripts matching the prefix.

```json
{
"scripts": {
"cypress": "cypress -help",
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"cypress:run:record": "cypress run --record"
}
}
```

In order to run "cypress" script use prefix with "." at the end:

```
# same as "npm run cypress"
$ nr c. # only finds single word starting with "c"
# same as "npm run cypress:open"
$ nr c-o.
# same as "npm run cypress:run"
$ nr c-r.
```

## Extra arguments

You can pass extra arguments right after the prefix string
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"fuzzy": "0.1.3",
"inquirer": "3.0.5",
"inquirer-autocomplete-prompt": "0.8.0",
"json-package": "1.2.2",
"json-package": "1.3.0",
"simple-bin-help": "1.7.0"
},
"devDependencies": {
Expand Down

0 comments on commit 2853e10

Please sign in to comment.