-
Notifications
You must be signed in to change notification settings - Fork 1
/
run
executable file
·57 lines (47 loc) · 1.27 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
#!/usr/bin/env bash
cmd="$1"
shift
run-usage() {
echo "run <cmd> [cmd args...]"
echo " build [nix-build args...] : build package"
echo " pack [yarn package args...] : pack package"
echo " publish [yarn publish args...] : publish package"
echo " name : print package name"
echo " version : print package version"
echo " usage : print this message"
}
run-build() {
nix-build "$@" && rsync -aL --delete --chmod +w result/ dist
}
run-pack() {
local name=$(run-name)
local ver=$(run-version)
run-build && (cd dist && yarn pack -f "../$name-v$ver.tgz" "$@")
}
run-publish() {
local ver=$(run-version)
run-build && (
cd dist && \
yarn publish \
--new-version "$ver" \
--no-git-tag-version \
--non-interactive \
"$@"
)
}
run-name() {
node -e 'console.log(require("./package.json").name);'
}
run-version() {
node -e 'console.log(require("./package.json").version);'
}
case "$cmd" in
build|pack|publish|version)
run-"$cmd" "$@"
;;
*)
echo "No such command: $cmd"
run-usage
exit 1
;;
esac