oclif-dev manifest
will execute your source code, why is this happening?
Step to reproduce:
- run
npx oclif multi mynewcli
- create an
index.ts
file under root foldersrc/app/index.ts
- you put
console.log("test...");
inside theindex.ts
file - import the file in your
src/commands/hello.ts
import { Command } from "@oclif/command";
import * as fs from "fs-extra";
+ import "../app/index";
export default class extends Command {
async run() {
}
}
- Now you run
yarn run prepack
, terminal shows
mynewcli % yarn run prepack
yarn run v1.22.4
$ rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme
test...
I thought oclif will only transpile your source code, turns out it executes it, that's quite strange when you're building an npm library.
The current solution is to write everything inside a function.