Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions custom-completions/npm/npm-completions.nu
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
def "nu-complete npm" [] {
^npm -l
|lines
|find 'Run "'
|str trim
|split column -c ' '
|get column4
|str replace '"' ''
let db = stor open

try {
# query commanders from in-mem db
$db | query db "SELECT * FROM npm_commanders_table"
} catch {
# if catched error, create table and insert all data
stor create --table-name npm_commanders_table --columns { value: str, description: str }

let npm_commanders = ^npm -l
| lines
| where $it =~ '\s{4}[a-z\-]+.*\s{4,}'
| parse -r '\s*(?P<value>[^ ]+)\s*(?P<description>\w.*)'

$npm_commanders | stor insert --table-name npm_commanders_table

$npm_commanders
}
}

export extern "npm" [
Expand All @@ -14,8 +25,9 @@ export extern "npm" [

def "nu-complete npm run" [] {
open ./package.json
|get scripts
|columns
| get scripts
| transpose
| rename value description
}

export extern "npm run" [
Expand Down