-
Notifications
You must be signed in to change notification settings - Fork 1
/
run
executable file
·66 lines (53 loc) · 1.85 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env fish
set npm_bin node_modules/.bin
function install -d "Install asdf and npm"
asdf install
npm install
end
function update -d "Update asdf and npm"
echo "Updating asdf"
asdf update
asdf plugin update --all
echo "Updating NPM"
npm outdated
npm update
end
function format -d "Format with prettier"
set --local opts --single-quote --write .
test -n "$argv"; and set opts $argv
$npm_bin/prettier $opts
end
function lint -d "Lint using typescript (tsc)"
$npm_bin/tsc $argv
end
function emit-dts -d "Emit typescript declaration"
set --local src "index.js"
set --local dst (string replace '.js' '.d.ts' $src)
set --local temp "$src.tmp"
set --local ref "/// <reference path='types.d.ts' />
"
rm $dst
$npm_bin/tsc --allowJs --declaration --noEmit false --emitDeclarationOnly $src
echo $ref | cat - $dst > $temp; mv $temp $dst
end
function tester -d "Run tests: specific file or test.js"
set --local files "test.js"
test -n "$argv"; and set files $argv
for f in $files; node $f; end
end
function doc -d "Generate README.md"
cat README.js.md | ./make-doc.js > tmp.js; and node tmp.js > README.md
end
################################################################################
# Run private
function _desc -d "Print a function's description"
set --local rx '^.+--description\s+[\'"]?((\\w|\\s)+).*' '$1'
echo (functions $argv[1] | string replace --filter --regex $rx)
end
function _help -d "Usage"
set --local rx '^\\s*function\\s+([^_]\\S+).*' '$1'
set --local tasks (cat (status filename) | string replace --filter --regex $rx)
printf '%s\n%s\n' 'run <task> [ rags ]' 'Available tasks:'
printf '%s\n' (for task in $tasks; echo -e "- $task\t"(_desc $task); end) | column -t -s\t
end
if functions --query $argv[1]; time $argv[1] $argv[2..-1]; else; _help; end