Skip to content

Commit

Permalink
Feat: add tsx as typescript runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Jan 14, 2025
1 parent 5acfdbe commit a10a396
Show file tree
Hide file tree
Showing 3 changed files with 280 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"scripts": {
"build": "tsc",
"start": "tsc && node ./dist/bin/cli.js",
"start": "tsx ./src/bin/cli.ts",
"lint": "eslint src",
"lint:fix": "eslint src --fix",
"release": "fixit-releaser changelog"
Expand All @@ -52,6 +52,7 @@
"@types/node": "^22.10.5",
"@types/shelljs": "^0.8.15",
"eslint": "^9.17.0",
"tsx": "^4.19.2",
"typescript": "^5.7.2"
}
}
271 changes: 271 additions & 0 deletions pnpm-lock.yaml

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

9 changes: 7 additions & 2 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@ interface Spinner {
message: (msg?: string) => void
}

/**
* The root directory of the project, determined by resolving the path of the current module
* and navigating two levels up the directory tree.
*/
const __root = join(dirname(fileURLToPath(import.meta.url)), '../..')

/**
* import json file
* @param {string} relativePath relative path to json file
* @returns {any} json object
*/
function importJson(relativePath: string): any {
const rootPath = dirname(fileURLToPath(new URL(import.meta.url))).replace(/\/dist\/lib$/, '')
const fileContent = readFileSync(join(rootPath, relativePath), 'utf8')
const fileContent = readFileSync(join(__root, relativePath), 'utf8')
return JSON.parse(fileContent)
}

Expand Down

0 comments on commit a10a396

Please sign in to comment.