trumbitta / nx-trumbitta

💡An attempt to start collecting all of my Nx-related Open Source work in a mono-repo.
MIT License
47 stars 11 forks source link

[bug] Silent property breaks generation #74

Closed iceteabottle closed 2 years ago

iceteabottle commented 2 years ago

Related to the last PR merge (https://github.com/trumbitta/nx-trumbitta/pull/71) I've found a bug with the brand new silent flag. The executor throws an exception if silent is set to true.

 >  NX   Cannot read properties of null (reading 'on')

TypeError: Cannot read properties of null (reading 'on')
    at /Users/username/dev/company/nx-project/node_modules/@trumbitta/nx-plugin-openapi/src/executors/generate-api-lib-sources/executor.js:46:26
    at new Promise (<anonymous>)
    at /Users/username/dev/company/nx-project/node_modules/@trumbitta/nx-plugin-openapi/src/executors/generate-api-lib-sources/executor.js:24:16
    at Generator.next (<anonymous>)
    at /Users/username/dev/company/nx-project/node_modules/tslib/tslib.js:117:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/Users/username/dev/company/nx-project/node_modules/tslib/tslib.js:113:16)
    at generateSources (/Users/username/dev/company/nx-project/node_modules/@trumbitta/nx-plugin-openapi/src/executors/generate-api-lib-sources/executor.js:22:20)
    at /Users/username/dev/company/nx-project/node_modules/@trumbitta/nx-plugin-openapi/src/executors/generate-api-lib-sources/executor.js:16:15
    at Generator.next (<anonymous>)

I got the same exception if I pass the option via config and cli.

PS: To be fair. The rest of the changes of the last PR works fine 🤓

youngchen7 commented 2 years ago

Oh interesting! I definitely had a test case that set silent to true - I'll have to look into this some more

youngchen7 commented 2 years ago

Ah I see - if stdio: 'ignore' is set node actually doesn't populate stdout or stderr at all - this wasn't caught because spawn was mocked in the unit tests.

https://nodejs.org/api/child_process.html#subprocessstderr

youngchen7 commented 2 years ago

Here's the fix 😄 https://github.com/trumbitta/nx-trumbitta/pull/76

trumbitta commented 2 years ago

@all-contributors please add @iceteabottle for reporting this bug

allcontributors[bot] commented 2 years ago

@trumbitta

I've put up a pull request to add @iceteabottle! :tada:

iceteabottle commented 2 years ago

@youngchen7 it works like a charm. Thanks for the fast fix.