Skip to content

Commit

Permalink
added --no-rebuild option
Browse files Browse the repository at this point in the history
  • Loading branch information
heartsucker committed Mar 5, 2017
1 parent e02e8f1 commit c3a8c10
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
specified on the command line.
- Allow `md5sums` to not be calculated.
- Deprecated the `--no-md5sums` CLI arg.
- Added
- `--no-rebuild` flag to prevent `postinst` maintainer script from running `npm rebuild`.
- Fixed
- `node_modules` is reduced down to only the production dependencies via `npm ls --prod`.

Expand Down
9 changes: 7 additions & 2 deletions node-deb
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ package_description=
package_maintainer=
package_dependencies=
node_deb_version=$(jq -r '.version' "$node_deb_dir/package.json")
# note: init is also injected
init=
no_rebuild=0

# Other variables
init=
no_delete_temp=0

usage() {
Expand Down Expand Up @@ -170,6 +170,10 @@ while [ -n "$1" ]; do
package_name="$value"
shift
;;
--no-rebuild)
# HELPDOC: On package installation, do not attempt `npm rebuild`.
no_rebuild=1
;;
--package-dependencies)
# HELPDOC: The dependencies for the Debian package (default: 'node_deb.dependencies')
zero_check "$value" "$param"
Expand Down Expand Up @@ -606,6 +610,7 @@ replace_vars() {
-e "s/{{ node_deb_user }}/$(escape "$user")/g" \
-e "s/{{ node_deb_group }}/$(escape "$group")/g" \
-e "s/{{ node_deb_init }}/$(escape "$init")/g" \
-e "s/{{ node_deb_no_rebuild }}/$(escape "$no_rebuild")/g" \
-e "s/{{ node_deb_version }}/$(escape "$node_deb_version")/g" \
> "$target_file"
### END TEMPLATE_VARS ###
Expand Down
9 changes: 6 additions & 3 deletions templates/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -e
set -o pipefail

declare -r init_type='{{ node_deb_init }}'
declare -ri no_rebuild='{{ node_deb_no_rebuild }}'

add_user() {
: ${1:?'User was not defined'}
Expand Down Expand Up @@ -69,15 +70,17 @@ start_service () {
}

npm_install() {
: {$1:?'Package name was not defined'}
: "${1:?'Package name was not defined'}"
cd "/usr/share/$1/app"

if [ ! -d './node_modules' ]; then
echo "Directory 'node_modules' did not exist. Running 'npm install'"
npm install --production
else
echo "Directory 'node_modules' exists. Running 'npm rebuild'"
npm rebuild --production
if [ "$no_rebuild" -eq 0 ]; then
echo "Directory 'node_modules' exists. Running 'npm rebuild'"
npm rebuild --production
fi
fi
}

Expand Down

0 comments on commit c3a8c10

Please sign in to comment.