Do not error out of npm install if postinstall fails.

The postinstall script will (rightly) return non-zero if the API
docs cannot be built, but this creates a problem when building a
container (Docker) image. In that case, we expect the postinstall
to fail, as the required files (spec/*) will not have been copied
into the image when `npm install` is run.

By adding an explicit OR clause we allow postinstall to end
gracefully whether or not the API docs have been built.
This commit is contained in:
D. Berge
2023-04-05 12:32:35 +02:00
parent 374739c133
commit 5a44e20a5b

View File

@@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "[[ -e ./node_modules/DOUGAL_ROOT ]] || ln -s .. ./node_modules/DOUGAL_ROOT; redoc-cli bundle ./spec/openapi.yaml -o ./spec/openapi.html"
"postinstall": "test -e node_modules/DOUGAL_ROOT || ln -s .. node_modules/DOUGAL_ROOT; test -e spec && test -e spec/openapi.yaml && node_modules/.bin/redoc-cli bundle ./spec/openapi.yaml -o ./spec/openapi.html || echo API documentation not present or failed to compile >/dev/stderr"
},
"author": "Aaltronav s.r.o.",
"license": "UNLICENSED",