Skip to content

Commit

Permalink
fix: template dir for when run via npx/npm
Browse files Browse the repository at this point in the history
  • Loading branch information
gmickel committed Jul 20, 2024
1 parent 76c9ff9 commit 7817b0b
Show file tree
Hide file tree
Showing 5 changed files with 494 additions and 357 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,4 @@ ehthumbs.db
Thumbs.db

todos.md
codewhisper.md
11 changes: 8 additions & 3 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ if (__dirname.includes(`${path.sep}dist`)) {

// Add this function to determine the templates directory
function getTemplatesDir() {
const isProduction = __dirname.includes(`${path.sep}dist`);
if (isProduction) {
return path.resolve(__dirname, '..');
if (__dirname.includes('node_modules')) {
// We're running from an installed package
return __dirname;
}
if (__dirname.includes(`${path.sep}dist`)) {
// We're running in production mode
return __dirname;
}
// We're running in development mode
return path.resolve(__dirname, 'src', 'templates');
}

Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "codewhisper",
"type": "module",
"version": "1.0.0",
"version": "0.1.0",
"description": "A powerful tool for converting repository code to AI-friendly prompts",
"author": "Gordon Mickel <[email protected]>",
"license": "MIT",
Expand Down Expand Up @@ -51,7 +51,7 @@
"prepare": "lefthook install"
},
"dependencies": {
"@inquirer/prompts": "^5.1.2",
"@inquirer/prompts": "5.2.1",
"chalk": "5.3.0",
"commander": "12.1.0",
"fast-glob": "3.3.2",
Expand All @@ -70,17 +70,17 @@
"@biomejs/biome": "1.8.3",
"@types/fs-extra": "11.0.4",
"@types/inquirer": "^9.0.7",
"@types/node": "20.14.10",
"@types/node": "20.14.11",
"@types/strip-comments": "2.0.4",
"@vitest/coverage-v8": "2.0.2",
"@vitest/ui": "2.0.2",
"@vitest/coverage-v8": "2.0.3",
"@vitest/ui": "2.0.3",
"bumpp": "9.4.1",
"esno": "4.7.0",
"lefthook": "1.7.2",
"tsup": "8.1.0",
"lefthook": "1.7.4",
"tsup": "8.2.0",
"typescript": "5.5.3",
"vite": "5.3.3",
"vitest": "2.0.2"
"vite": "5.3.4",
"vitest": "2.0.3"
},
"packageManager": "[email protected]",
"workspaces": ["apps/*", "packages/*"],
Expand Down
Loading

0 comments on commit 7817b0b

Please sign in to comment.