This repository has been archived by the owner on Apr 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
npm_install.sh
executable file
·55 lines (45 loc) · 1.53 KB
/
npm_install.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
#!/bin/bash
# Exit on error to prevent a build
set -e
# Variable setup
BUILD_DIR="$(pwd)"
DEB_BUILD=false
if [[ $BUILD_DIR == *debian/build ]]
then
BUILD_DIR="$(pwd)/../.."
DEB_BUILD=true
fi
BUILD_NAME="com.github.harisvsulaiman.pushy.node"
NODE_DIR="$BUILD_DIR/$BUILD_NAME"
# Add node related directories to path
export PATH="$PATH:/usr/local/bin"
export PATH="$PATH:/tmp/bin"
export PATH="$PATH:$HOME/.npm-packages/bin"
export PATH="$PATH:$HOME/.npm/.bin"
export PATH="$PATH:$BUILD_DIR/node_modules/.bin"
export PATH="$PATH:$BUILD_DIR/../../node_modules/.bin"
# Remove any already built code
echo "Deleting files already built"
rm -rf ${NODE_DIR}
rm -rf ${BUILD_DIR}/node_modules
# Install node dependencies.
echo "Installing npm dependencies in $BUILD_DIR"
HOME=/tmp npm install
HOME=/tmp NPM_CONFIG_PREFIX=/tmp npm install -g pkg
# Setup workspace
mkdir ${NODE_DIR}
# Build app using pkg
echo "Building binary using pkg"
HOME=/tmp npm run build
echo "Copying .node files from ${BUILD_DIR}"
cp $BUILD_DIR/node_modules/keytar/build/Release/keytar.node ${NODE_DIR}
cp $BUILD_DIR/node_modules/abstract-socket/build/Release/abstract_socket.node ${NODE_DIR}
cp $BUILD_DIR/node_modules/websocket/build/Release/bufferutil.node ${NODE_DIR}
cp $BUILD_DIR/node_modules/websocket/build/Release/validation.node ${NODE_DIR}
cp $BUILD_DIR/node_modules/opn/xdg-open ${NODE_DIR}
if [ "$BUILD_DEB" = true ]
then
echo "Copying built directory from ${BUILD_DIR}"
mkdir -p $BUILD_DIR/debian/build/$BUILD_NAME
cp $NODE_DIR/* $BUILD_DIR/debian/build/$BUILD_NAME/
fi