Preserving node_modules between builds

cc @khem

One thing I like to do is use NPM and Go modules for managing building dependencies of apps that use these technologies. Typically, I’ll specify dependencies in go.mod and package.json where I lock down versions. However, it would be nice if these dependencies (node_modules and GOPATH – I think) were cached globally so you did not have to download dependencies on every build. I’ve done something like the following with GOPATH – would be neat to find something similar for node_modules.

S = "${WORKDIR}/git"

GOPATH = "${TMPDIR}/work-shared/go"

INITSCRIPT_NAME = "isapp"
INITSCRIPT_PARAMS = "start 99 5 . stop 20 6 ."

do_configure() {
  export GOPATH=${GOPATH}
  go install github.com/benbjohnson/genesis/...
}

do_compile() {
  export GOPATH=${GOPATH}
  export PATH=${GOPATH}/bin:$PATH
  source ./is-envsetup.sh
  # FIXME: get elm cache in ~/.elm moved to work-shared
  rm -rf frontend/elm-stuff
  is_build_frontend
  is_build_assets
  GOARCH=arm go build -o is farmation/cmd/injector-sentry/main.go
}