Skip to content

Commit

Permalink
feat: migrate to unjs/citty (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 authored Jul 18, 2023
1 parent a2e7fd2 commit 607fee9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 25 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@rollup/plugin-replace": "^5.0.2",
"@rollup/pluginutils": "^5.0.2",
"chalk": "^5.3.0",
"citty": "^0.1.2",
"consola": "^3.2.3",
"defu": "^6.1.2",
"esbuild": "^0.18.14",
Expand All @@ -44,7 +45,6 @@
"magic-string": "^0.30.1",
"mkdist": "^1.3.0",
"mlly": "^1.4.0",
"mri": "^1.2.0",
"pathe": "^1.1.1",
"pkg-types": "^1.0.3",
"pretty-bytes": "^6.1.1",
Expand All @@ -54,7 +54,6 @@
"untyped": "^1.3.2"
},
"devDependencies": {
"@types/mri": "^1.1.1",
"@types/node": "^20.4.2",
"@vitest/coverage-v8": "^0.33.0",
"changelogen": "^0.5.4",
Expand Down
13 changes: 3 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 28 additions & 13 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
#!/usr/bin/env node
import { defineCommand, runMain } from "citty";
import { resolve } from "pathe";
import mri from "mri";
import { name, version, description } from "../package.json";
import { build } from "./build";

async function main() {
const args = mri(process.argv.splice(2));
const rootDir = resolve(process.cwd(), args._[0] || ".");
await build(rootDir, args.stub).catch((error) => {
console.error(`Error building ${rootDir}: ${error}`);
throw error;
});
}

main().catch((error) => {
console.error(error);
process.exit(1);
const main = defineCommand({
meta: {
name,
version,
description,
},
args: {
dir: {
type: "positional",
description: "The directory to build",
required: false,
},
stub: {
type: "boolean",
description: "Stub build",
},
},
async run({ args }) {
const rootDir = resolve(process.cwd(), args.dir || ".");
await build(rootDir, args.stub).catch((error) => {
console.error(`Error building ${rootDir}: ${error}`);
throw error;
});
},
});

runMain(main);

0 comments on commit 607fee9

Please sign in to comment.