Skip to content

Commit 0e80f9e

Browse files
committed
fix(cli): expose main and run it from bin
1 parent 4d0e2fa commit 0e80f9e

File tree

4 files changed

+14
-36
lines changed

4 files changed

+14
-36
lines changed

bin/nuxt-telemetry.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
#!/usr/bin/env node
22
process._startTime = Date.now()
3-
import('../dist/cli.mjs').then(r => (r.default || r).main())
3+
import('../dist/cli.mjs').then(r => (r.default || r).main().catch((error) => {
4+
console.error(error)
5+
process.exit(1)
6+
}))

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"dev:generate": "NUXT_TELEMETRY_DEBUG=1 nuxi generate playground",
2929
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
3030
"lint": "eslint .",
31-
"nuxt-telemetry": "jiti ./src/cli.ts",
31+
"nuxt-telemetry": "node ./bin/nuxt-telemetry.mjs",
3232
"prepack": "nuxt-module-build build",
3333
"release": "pnpm test && pnpm build && pnpm changelogen --release --push && pnpm publish",
3434
"test": "vitest run",
@@ -72,6 +72,9 @@
7272
"vitest": "^2.1.8",
7373
"vue-tsc": "^2.1.10"
7474
},
75+
"resolutions": {
76+
"@nuxt/telemetry": "workspace:*"
77+
},
7578
"engines": {
7679
"node": ">=18.20.5"
7780
}

pnpm-lock.yaml

Lines changed: 5 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const sharedArgs = {
2929
},
3030
} as const
3131

32-
const cli = createMain({
32+
export const main = createMain({
3333
meta: {
3434
name: 'nuxt-telemetry',
3535
description: 'Manage consent for Nuxt collecting anonymous telemetry data about general usage.',
@@ -173,8 +173,3 @@ function ensureNuxtProject(args: { global: boolean, dir: string }) {
173173
process.exit()
174174
}
175175
}
176-
177-
cli().catch((error) => {
178-
console.error(error)
179-
process.exit(1)
180-
})

0 commit comments

Comments
 (0)