Skip to content

bug(cli): node src/cli.js exits 0 with no output — missing self-invocation #113

@devswha

Description

@devswha

Summary

Running node src/cli.js <args> exits 0 with no output (stdout + stderr both empty). The correct entry point bin/patina.js works fine.

Root Cause

src/cli.js exports main() but never calls it at module level. When Node executes the file directly, it defines/exports the function and exits cleanly — no work is performed.

bin/patina.js correctly calls main(process.argv.slice(2)), so npx patina works. Only the node src/cli.js invocation path is broken.

Reproduction

node src/cli.js --backend codex-cli --tone casual --lang ko input.txt
# → exit 0, no output

node bin/patina.js --backend codex-cli --tone casual --lang ko input.txt
# → correct output

Suggested Fix

Add an ESM self-invocation guard at the bottom of src/cli.js:

import { fileURLToPath } from 'node:url';

if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
  main(process.argv.slice(2)).catch((err) => { console.error(err); process.exit(1); });
}

This preserves importability (tests import main() without side effects) while making node src/cli.js work as expected.

References

  • src/cli.js:18main() defined and exported, never called
  • bin/patina.js:5 — correct pattern already in use
  • package.json "main": "src/cli.js" implies it should be self-executing

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions