{"record":{"id":"0d439c0041d07bfb","repo":"paperclipai/paperclip","slug":"usage-prepare-npm-readme-mjs-source-destination-asset-ref","errorCode":null,"errorMessage":"usage: prepare-npm-readme.mjs <source> <destination> <asset-ref>","messagePattern":"usage: prepare-npm-readme\\.mjs <source> <destination> <asset-ref>","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/prepare-npm-readme.mjs","lineNumber":29,"sourceCode":"    `https://raw.githubusercontent.com/paperclipai/paperclip/${assetRef}/doc/assets/`;\n\n  return readme.replace(\n    /((?:src|srcset)=[\"'])([^\"']*)([\"'])/g,\n    (_match, prefix, value, suffix) =>\n      `${prefix}${value.replace(\n        /(^|,\\s*)doc\\/assets\\//g,\n        `$1${assetBaseUrl}`,\n      )}${suffix}`,\n  );\n}\n\nconst isDirectRun =\n  process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);\n\nif (isDirectRun) {\n  const [sourcePath, destinationPath, assetRef] = process.argv.slice(2);\n  if (!sourcePath || !destinationPath || !assetRef) {\n    throw new Error(\n      \"usage: prepare-npm-readme.mjs <source> <destination> <asset-ref>\",\n    );\n  }\n\n  writeFileSync(\n    destinationPath,\n    prepareNpmReadme(readFileSync(sourcePath, \"utf8\"), assetRef),\n  );\n}\n","sourceCodeStart":11,"sourceCodeEnd":39,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/scripts/prepare-npm-readme.mjs#L11-L39","documentation":"When prepare-npm-readme.mjs is executed directly (process.argv[1] resolves to the module file), it expects exactly three CLI arguments: source README path, destination path, and the immutable asset ref. Missing any of them aborts with the usage line, since it cannot guess where to read, write, or which ref to pin.","triggerScenarios":"Running `node scripts/prepare-npm-readme.mjs` or with fewer than three space-separated arguments; quoting mistakes that collapse arguments (e.g. passing \"README.md dist/\" as one token); calling the script from a wrapper that drops the asset-ref argument.","commonSituations":"Copy-pasting the command from docs but omitting the ref; shell variable expansions resolving to empty strings (e.g. $COMMIT_SHA unset); CI steps edited to remove what looked like a redundant argument.","solutions":["Run with all three arguments: node scripts/prepare-npm-readme.mjs <source> <destination> <asset-ref>.","If the ref comes from an env var or command substitution, echo it first to confirm it is non-empty before invoking.","Quote each path argument in the shell so spaces or empty variables do not collapse positional arguments."],"exampleFix":"// before (shell)\nnode scripts/prepare-npm-readme.mjs README.md dist/README.md $REF\n// after\nREF=$(git rev-parse HEAD); node scripts/prepare-npm-readme.mjs README.md dist/README.md \"$REF\"","handlingStrategy":"validation","validationCode":"const [sourcePath, destinationPath, assetRef] = process.argv.slice(2);\nif (!sourcePath || !destinationPath || !assetRef) {\n  console.error('usage: prepare-npm-readme.mjs <source> <destination> <asset-ref>');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"try { main(); } catch (e) { if (e.message.startsWith('usage: prepare-npm-readme')) { console.error(e.message); process.exit(1); } throw e; }","preventionTips":["Quote all path arguments and verify env-derived refs are non-empty before invoking.","Check the script's usage line with --help-style invocation when unsure of argument order.","In CI, add a pre-step echoing all three resolved arguments before running the script."],"tags":["cli","usage","missing-argument"],"backgroundTag":"missing-cli-argument","analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-09-18T08:03:59.046Z","contentChangedAt":"2026-09-18T08:03:59.046Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}