Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #242 from Financial-Times/package-lock
Browse files Browse the repository at this point in the history
  • Loading branch information
apaleslimghost authored Nov 2, 2020
2 parents 0c6fe24 + 24b518f commit 445fb0a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions secret-squirrel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
allow: [
'dotfiles/.stylelintrc',
'dotfiles/.editorconfig',
'.nvmrc',
'.*.mk'
],
allowOverrides: []
Expand Down
6 changes: 0 additions & 6 deletions src/setup.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,9 @@ endif
# misc/legacy
GLOB = git ls-files -z $1 | tr '\0' '\n' | xargs -I {} find {} ! -type l

NPM_INSTALL = npm prune --production=false --no-package-lock && npm install --no-package-lock
BOWER_INSTALL = rm -rf bower_components && bower install --config.registry.search=https://origami-bower-registry.ft.com --config.registry.search=https://registry.bower.io

JSON_GET_VALUE = grep $1 | head -n 1 | sed 's/[," ]//g' | cut -d : -f 2
APP_NAME = $(shell cat package.json 2>/dev/null | $(call JSON_GET_VALUE,name))

IS_GIT_IGNORED = grep -q $(if $1, $1, $@) .gitignore
REPLACE_IN_GITIGNORE = sed -i -e 's/$1/$2/g' .gitignore && rm -f .gitignore-e ||:

# functions for eye-catching terminal output
COLOR = $(shell /usr/bin/env PATH=$(PATH) FORCE_COLOR=1 chalk --no-stdin -t "$1 ")
CAPITALISE = $(shell STR="$1"; echo "$$(tr '[:lower:]' '[:upper:]' <<<"$${STR:0:1}")$${STR:1}")
Expand Down
20 changes: 17 additions & 3 deletions src/tasks/install.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,31 @@ instal%: node_modules bower_components dotfiles
@if [ -z $(CIRCLECI) ] && [ ! -e .env ]; then (echo "Note: If this is a development environment, you will likely need to import the project's environment variables by running 'make .env'."); fi

# INSTALL SUB-TASKS
IS_GIT_IGNORED = grep -q $(if $1, $1, $@) .gitignore

# if package-lock.json is in gitignore, don't create it, and prune
# before install to match the behaviour with package-lock.json
define NPM_INSTALL
if $(call IS_GIT_IGNORED,package-lock.json); then \
npm prune --no-production --no-package-lock \
&& npm install --no-package-lock ;\
else \
npm install ;\
fi
endef

BOWER_INSTALL = rm -rf bower_components && bower install --config.registry.search=https://origami-bower-registry.ft.com --config.registry.search=https://registry.bower.io

# Regular npm install
node_modules: package.json
@if [ -e package-lock.json ]; then rm package-lock.json; fi
@if [ -e package.json ]; then mkdir -p node_modules && touch node_modules/.metadata_never_index && $(NPM_INSTALL) && $(DONE); fi
@if [ -e package-lock.json ] && $(call IS_GIT_IGNORED,package-lock.json); then rm package-lock.json; fi
@if [ -e package.json ]; then $(NPM_INSTALL) && $(DONE); fi

# Regular bower install
bower_components: bower.json
@if [ -e bower.json ]; then $(BOWER_INSTALL) && $(DONE); fi

# These tasks have been intentionally left blank
# These tasks have been intentionally left blank (why)
package.json:
bower.json:

Expand Down

0 comments on commit 445fb0a

Please sign in to comment.