adelsz / pgtyped

pgTyped - Typesafe SQL in TypeScript
https://pgtyped.dev
MIT License
2.91k stars 94 forks source link

`failOnError` does not abort generation #574

Open KieranKaelin opened 5 months ago

KieranKaelin commented 5 months ago

Describe the bug @pgtyped/cli does not respect the failOnError flag during generation.

Expected behavior The workers should stop, and the process should exit with code 1.

Test case


From my novice eye, it seems that this regression stems from e5f920e (as cdfadfba, the previous commit, is working as expected), specifically the changes in packages/cli/src/index.ts#L40.

I made a quick local test, replacing this.pool.run(opts, { name: functionName }); with

const result = await this.pool.run(opts, { name: functionName });
if (result.error) {
  throw result.error;
}
return result;

Rerunning npm run typegen now behaves as expected, immediately stopping all workers as it encounters the erroneous file, and exiting with code 1.

mrjackdavis commented 4 months ago

Here's an unfortunate workaround for those who butt up against this

pgtyped -c ./pgtyped.config.cjs 2>&1 | tee  /dev/tty | grep 'Error:' && exit 1 || exit 0