Skip to content
This repository was archived by the owner on Jul 30, 2026. It is now read-only.
This repository was archived by the owner on Jul 30, 2026. It is now read-only.

pg-node: npm run send passes a --send flag that index.mjs silently ignores #52

Description

@dobby-coder

Problem

In pg-node/package.json:

"send":   "node --env-file-if-exists=.env index.mjs --send",
"upload": "node --env-file-if-exists=.env index.mjs --upload-only"

But pg-node/index.mjs:30 only inspects one flag:

const mode = process.argv.includes('--upload-only') ? 'upload-only' : 'send-email';

--send is parsed as no flag at all — the mode falls through to the default `send-email` branch. This works by coincidence today: anyone copying `npm start` (which has no flag) also gets send-email, so behaviour matches the script names. But:

  • Adding a future mode (e.g. `--dry-run`) makes `--send` look load-bearing when it isn't.
  • A typo like `--Send` would also "work", masking the bug.
  • The CLI usage block in `index.mjs` only mentions npm scripts, not raw flags — so the inconsistency is invisible from a quick read.

Suggested fix

Either:

  1. Drop `--send` from the npm script (preferred — keep the flag set minimal):
"send": "node --env-file-if-exists=.env index.mjs"
  1. Or honour `--send` explicitly in `index.mjs` and reject unknown flags:
const args = process.argv.slice(2);
const mode =
  args.includes('--upload-only') ? 'upload-only' :
  args.includes('--send')        ? 'send-email' :
  'send-email';

Option 1 is the smaller, more honest fix.

Files

  • pg-node/package.jsonsend script
  • pg-node/index.mjs:30 — mode parsing

Metadata

Metadata

Assignees

No one assigned

    Labels

    choreRoutine maintenance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions