buddy ts copy-cjs-package-json
buddy ts copy-cjs-package-json <dir> [cwd] copies package.cjs.json
to <cwd>/<dir>/package.json. Use it after a CommonJS build step that buddy ts build does not run, such as esbuild.
buddy ts copy-cjs-package-json <dir> [cwd]
# aliasbuddy ts cpj <dir> [cwd]Requires the plugin to be enabled.
Arguments
Section titled “Arguments”| Argument | Type | Default | Effect |
|---|---|---|---|
dir |
string | required | The output folder of the CommonJS build, relative to cwd. |
cwd |
string | process.cwd() |
The project directory. |
The command has no flags.
Before @repobuddy/typescript 2.2.2, the CLI treated cwd as required: buddy ts cpj cjs exited with code 2
and missing required argument <cwd>. On those versions, pass . for the current directory.
Output
Section titled “Output”copy-cjs-package-json: starts...copy-cjs-package-json: completedExit codes
Section titled “Exit codes”| Code | When |
|---|---|
0 |
The file was copied. |
1 |
<cwd>/<dir> does not exist (ENOENT, printed as an uncaught error). |
2 |
dir is missing. |
Behavior
Section titled “Behavior”- It does not create
<dir>. Run it after the build that creates the folder. - It overwrites an existing
<dir>/package.json.
Examples
Section titled “Examples”Copy into cjs/ in the current directory:
buddy ts cpj cjsCopy into another project’s output folder:
buddy ts copy-cjs-package-json out ../my-packageThis writes ../my-package/out/package.json with { "type": "commonjs" }.