Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/hydrojudge/bin/hydrojudge.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

const argv = require('cac')().cac().parse();
const argv = require('cac').cac().parse();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

Does cac 7.0.0 npm package export a named cac function accessible via require('cac').cac in CommonJS?

💡 Result:

No, the cac 7.0.0 npm package does not export a named cac function accessible via require('cac').cac in CommonJS. In version 7.0.0, CAC removed its CJS build and is now ESM-only, with "type": "module" in package.json and exports pointing to./dist/index.js.[1][2] The official release notes explicitly state: "Remove CJS build. CAC is now ESM-only. If you rely on require(), either migrate to ESM imports or upgrade to Node.js ≥ 20.19.0, which supports require() for ES modules natively."[1] While Node.js >=20.19.0 allows require on ESM modules (returning the default export), it provides the default export directly as require('cac'), not as a named property.cac. All documentation and examples use import cac from 'cac' or const cli = cac(), confirming cac is the default export, with no evidence of named exports like { cac }.[3][4][5]

Citations:


The fix require('cac').cac() is incorrect for cac 7.0.0.

cac 7.0.0 removed its CJS build and is now ESM-only. According to the official release notes, require('cac') on Node.js ≥20.19.0 returns the default export directly—the cac function itself. There is no named cac property; accessing require('cac').cac will fail.

For CommonJS with Node ≥20.19.0, use:

const argv = require('cac')().parse();

For ESM (recommended), migrate to:

import cac from 'cac';
const argv = cac().parse();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/hydrojudge/bin/hydrojudge.js` at line 3, The current call uses
require('cac').cac() which fails with cac 7 because the module exports the caf
function directly; update the code that sets argv (the expression using
require('cac').cac()) to call the default export instead: either change to
require('cac')().parse() for CommonJS on Node >=20.19.0, or migrate the file to
ESM and import the default (import cac from 'cac'; const argv = cac().parse())
so argv is created from a proper cac() call.

require('@hydrooj/register');

if (argv.args[0] === 'cache') require('../src/cache')();
Expand Down
Loading