-
Notifications
You must be signed in to change notification settings - Fork 495
/
50_node.sh
29 lines (23 loc) · 868 Bytes
/
50_node.sh
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
[[ "$1" != init && ! -e ~/.volta ]] && return 1
export VOLTA_HOME=~/.volta
grep --silent "$VOLTA_HOME/bin" <<< $PATH || export PATH="$VOLTA_HOME/bin:$PATH"
# Use npx instead of installing global npm modules
function make_npx_alias () {
alias $1="npx $@"
}
make_npx_alias json2yaml
make_npx_alias pushstate-server
make_npx_alias yaml2json
function get_last_modified_js_file_recursive() {
find . -type d \( -name node_modules -o -name .git -o -name .build \) -prune -o -type f \( -name '*.js' -o -name '*.jsx' \) -print0 \
| xargs -0 stat -f '%m %N' \
| sort -rn \
| head -1 \
| cut -d' ' -f2-
}
function watchfile() {
yarn watch --testPathPattern "$(get_last_modified_js_file_recursive | sed -E 's#.*/([^/]+)/([^.]+).*#\1/\2.#')"
}
function watchdir() {
yarn watch --testPathPattern "$(dirname "$(get_last_modified_js_file_recursive)")"
}