fix(scripts): stop hiding build failures in the setup scripts

`prepare.sh` and `run-integration.sh` sent the build output to /dev/null and had no
shebang, no `set -e` and no exit status check. A failed build was invisible, the script
carried on into the Docker steps and still exited 0.

The `&>` redirect was also not portable. Under dash, which is /bin/sh on most Debian and
Ubuntu systems, it parses as "run in the background" plus a separate no-op redirect, so
the build raced the steps that followed instead of being muted.

Adds `#!/usr/bin/env bash` and `set -eu` to both scripts and drops the redirect.
`pipefail` is left out on purpose so the scripts still work when invoked with `sh` on a
dash system; neither script uses a pipeline and neither reads a shell variable.

Also corrects CONTRIBUTING.md. `npm run build` runs `move:node_modules`, which copies the
compiled output into the root `node_modules/@nestjs`; `move:samples` is a separate task
that only `build:samples` invokes. Two places claimed the build moves packages into the
`sample` directories. `prepare.sh` also starts Docker containers and waits for RabbitMQ,
which its description did not mention, and `npm run test` needs neither a build nor
Docker, so it now comes before the integration setup.
This commit is contained in:
snowykte0426 authored and Kamil Mysliwiec committed 2026-08-30 20:13:06 +02:00
1 parent a9bf20b693
commit 75958d7ab1
3 files changed
+26 -8

No files matched your search

+17 -5
View File
@@ -166,18 +166,30 @@ You will need [Node.js](https://nodejs.org) version >= 20.
$ npm ci --legacy-peer-deps # (or yarn install)
```
2. In order to prepare your environment run `prepare.sh` shell script:
2. To run the unit tests you are ready to go:
```bash
$ sh scripts/prepare.sh
$ npm run test
```
That will compile fresh packages and afterward, move them all to `sample` directories.
The unit tests run straight from the TypeScript sources, so no build step and no Docker
are required.
3. Only if you are going to run the **integration** tests, prepare that environment with
the `prepare.sh` shell script:
```bash
$ bash scripts/prepare.sh
```
That will compile fresh packages into the root `node_modules/@nestjs`, then start the
Docker containers the integration tests need and wait for RabbitMQ to accept
connections. Docker is required for this step.
### <a name="common-scripts"></a>Commonly used NPM scripts
```bash
# build all packages and move to "sample" directories
# build all packages into the root node_modules/@nestjs
$ npm run build
# run the full unit tests suite
@@ -185,7 +197,7 @@ $ npm run test
# run integration tests
# docker is required(!)
$ sh scripts/run-integration.sh
$ bash scripts/run-integration.sh
# run linter
$ npm run lint
Regular → Executable
+4 -1
View File
@@ -1,5 +1,8 @@
#!/usr/bin/env bash
set -eu
# 1. Build fresh packages and move them to sample and integration directories
npm run build &>/dev/null
npm run build
# 2. Start docker containers to perform integration tests
npm run test:docker:up
+5 -2
View File
@@ -1,5 +1,8 @@
# 1. Build fresh packages and move them integration dit
npm run build &>/dev/null
#!/usr/bin/env bash
set -eu
# 1. Build fresh packages and move them to the integration directory
npm run build
# 2. Start docker containers to perform integration tests
npm run test:docker:up