Skip to content

Commit

Permalink
fix(cli): #317 cli on node 22
Browse files Browse the repository at this point in the history
Use require instead import assertion to support node 20 and 22.

Closes: #314
  • Loading branch information
sdorra authored Sep 20, 2024
1 parent 67f4d46 commit 9a7795d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-tigers-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@content-collections/cli": patch
---

Fix cli on node 22
5 changes: 2 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"description": "Command line interface for content-collections",
"version": "0.1.3",
"type": "module",
"main": "dist/src/index.js",
"main": "dist/index.js",
"files": [
"dist",
"README.md"
],
"bin": {
"content-collections": "dist/src/index.js"
"content-collections": "dist/index.js"
},
"scripts": {
"build": "tsc",
Expand All @@ -22,7 +22,6 @@
"devDependencies": {
"@content-collections/core": "workspace:*",
"@types/node": "^20.14.9",
"tsup": "^8.2.4",
"tsx": "^4.1.1",
"typescript": "^5.5.4"
},
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#!/usr/bin/env node
import { Clerc, completionsPlugin, helpPlugin, versionPlugin } from "clerc";
import packageJson from "../package.json" assert { type: "json" };
import build from "./commands/build.js";
import watch from "./commands/watch.js";

import { createRequire } from "node:module";
const require = createRequire(import.meta.url);
const packageJson = require("../package.json");

const name = "content-collections";
if (!packageJson.bin[name]) {
throw new Error(`Missing bin entry for ${name} in package.json`);
Expand Down
4 changes: 1 addition & 3 deletions pnpm-lock.yaml

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

0 comments on commit 9a7795d

Please sign in to comment.