-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcopy-local-to-deps.sh
executable file
·57 lines (40 loc) · 1.37 KB
/
copy-local-to-deps.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
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
#!/bin/bash
set -e
USAGE="=======================================================================
copy-local-to-deps.sh <path>
Copies a local node path to the deps and marks the directory read-only. This
assumes that all the sources lie within the src/ tree, so is of limited use
generally. However, it's useful for copying glift-core into the deps tree.
Eventually, this will support pulling directly from Github.
Example:
copy-local-to-deps.sh ../glift-core"
# Ensure the REPO_PATH always has a trailing slash.
readonly REPO_PATH=${@%/}/
echo "Using repopath $REPO_PATH"
if [[ -z $REPO_PATH ]]; then
echo "You must supply a path for the local repo!!"
echo "$USAGE" >&2
exit 1
fi
if [[ ! -d $REPO_PATH ]]; then
echo "Path supplied was not a directory!"
echo "$USAGE" >&2
exit 1
fi
if [[ ! -f ${REPO_PATH}package.json ]]; then
echo "Could not find a package.json!"
echo "$USAGE" >&2
exit 1
fi
readonly name=$(grep "^ \"name\":.*" ${REPO_PATH}package.json | sed "s/.*\"\(.*\)\"[^:].*/\1/g")
if [[ -z $name ]]; then
echo "Could not find the package.json!"
echo "$USAGE" >&2
exit 1
fi
readonly SRC_PATH="${REPO_PATH}src"
readonly LIB_PATH=$(echo $0 | sed "s/\\/[^/]*$/\\//g")deps/$name
# echo "Copying $SRC_PATH to $LIB_PATH"
# Ensure that the dirs are readonly.
rsync -r $SRC_PATH/* $LIB_PATH
find $LIB_PATH -name "*.js" -print | xargs chmod a-w