forked from nodenv/node-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubmit-definitions
executable file
·45 lines (34 loc) · 1.26 KB
/
submit-definitions
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
#!/usr/bin/env bash
# Usage: script/update-nodes [-r [<remote>]]
#
# scrapes, commits, pushes, and pull-requests new node definitions
#
# * inspired by: https://github.com/jasonkarns/brew-publish *
set -e
while getopts ":r" opt; do
case $opt in
r) remote="${OPTARG:-origin}" ;;
:) abort "Option -$OPTARG requires an argument." ;;
\?) abort "Invalid option: -$OPTARG" ;;
esac
done
if ! type -p hub >/dev/null; then
abort "ERROR: You have to install hub to proceed."
fi
if [ -z "$remote" ]; then
# hackish way of getting the git remote name for user's fork
remote="$(hub fork 2>&1 | grep -oE 'remote:? \S+' | tail -1 | awk '{print $2}')"
fi
git fetch --quiet --unshallow origin master 2>/dev/null || git fetch --quiet origin master
git checkout --quiet origin/master
npm run-script scrape-definitions
for node_def in $(git ls-files --others --exclude-standard -- share/node-build/); do
node_name="$(basename "$node_def")"
git checkout --quiet -B "node/$node_name" origin/master
git add -- "$node_def"
git commit --message "$node_name" --message "Created with \`npm run submit-definitions\`." --only -- "$node_def"
git push --set-upstream "$remote" HEAD
hub pull-request --message "$node_name"
git checkout --quiet -
done
git checkout --quiet master