diff --git a/.changeset/many-socks-cheat.md b/.changeset/many-socks-cheat.md new file mode 100644 index 00000000..71bcebfe --- /dev/null +++ b/.changeset/many-socks-cheat.md @@ -0,0 +1,16 @@ +--- +'@contentlayer/cli': patch +--- + +Fix exit code error in build command on **Node 20+**: + +```sh +Generated 100 documents in .contentlayer +TypeError: The "code" argument must be of type number. Received an instance of Object + at process.set [as exitCode] (node:internal/bootstrap/node:123:9) + at Cli.runExit (./node_modules/@contentlayer/cli/node_modules/clipanion/lib/advanced/Cli.js:232:26) + at run (file:///./node_modules/@contentlayer/cli/src/index.ts:39:3) + at main (./node_modules/contentlayer/bin/cli.cjs:5:3) { + code: 'ERR_INVALID_ARG_TYPE' +} +``` diff --git a/packages/@contentlayer/cli/src/commands/BuildCommand.ts b/packages/@contentlayer/cli/src/commands/BuildCommand.ts index 4d96bc33..ece34cc8 100644 --- a/packages/@contentlayer/cli/src/commands/BuildCommand.ts +++ b/packages/@contentlayer/cli/src/commands/BuildCommand.ts @@ -25,6 +25,7 @@ export class BuildCommand extends BaseCommand { T.tap((config) => (config.source.options.disableImportAliasWarning ? T.unit : T.fork(core.validateTsconfig))), T.chain((config) => core.generateDotpkg({ config, verbose: this.verbose })), T.tap(core.logGenerateInfo), + T.map(() => 0), OT.withSpan('@contentlayer/cli/commands/BuildCommand:executeSafe'), ) }