Skip to content

Commit 7c62b53

Browse files
🐛 Fix(commitsmile): Problem with init template (wrong template path)
1 parent 979c24f commit 7c62b53

3 files changed

Lines changed: 32 additions & 5 deletions

File tree

packages/commitsmile/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# commitsmile
22

3+
## 1.0.3
4+
5+
### Patch Changes
6+
7+
- fix: template path update
8+
39
## 1.0.2
410

511
### Patch Changes

packages/commitsmile/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "commitsmile",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Make smile on your commits",
55
"keywords": [
66
"commit",
@@ -32,7 +32,7 @@
3232
"main": "index.js",
3333
"bin": {
3434
"commitsmileBuild": "./bin/app.js",
35-
"commitsmileDev": "./bin/app.js"
35+
"commitsmileDev2": "./bin/app.js"
3636
},
3737
"scripts": {
3838
"build": "pnpm tsup --config ./config/tsuprc/tsup.prod.ts",

packages/commitsmile/src/cli/init.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { TOptionsConfig, TOptionsDebugger } from "@/helpers";
12
import { optionDebugger } from "@/helpers";
23
import * as prompter from "@clack/prompts";
34
import { program } from "commander";
@@ -10,11 +11,23 @@ import { copyFile, existsSync } from "node:fs";
1011
import { fileURLToPath } from "node:url";
1112
import path, { dirname } from "node:path";
1213

14+
//----------------------
15+
// Types
16+
//----------------------
17+
/** @internal @dontexport */
18+
type TOptions = TOptionsConfig & TOptionsDebugger;
19+
20+
//----------------------
21+
// CLI APP
22+
//----------------------
1323
program
1424
.command("init")
25+
.addOption(optionDebugger) //TODO: Fix to make it work (Only work in one command at time rn)
1526
.description("Init configuration file")
16-
.addOption(optionDebugger)
17-
.action(async () => {
27+
.action(async (options: TOptions) => {
28+
process.env.DEBUG = options.debugger ? "TRUE" : "FALSE";
29+
logging.debug("Test debug message");
30+
logging.debug(options);
1831
const test = await new StageRunner()
1932
.addStep({
2033
intro: () => {
@@ -104,9 +117,14 @@ program
104117
const destination = `${process.cwd()}/${finalname}`;
105118
const templatePath = path.resolve(
106119
dirname(fileURLToPath(import.meta.url)),
107-
`./templates/configs/config.${ext}.hbs`
120+
`../templates/configs/config.${ext}.hbs`
108121
);
109122

123+
logging.debug(`Template Path: ${templatePath}`);
124+
125+
//TODO: Error if it do not exist
126+
logging.debug(`Template Path Exist: ${existsSync(templatePath)}`);
127+
110128
if (existsSync(destination)) {
111129
logging.warn("File already exists!");
112130
const overwrite = await prompter.confirm({ message: "Overwrite file?", initialValue: false });
@@ -119,6 +137,7 @@ program
119137
copyFile(templatePath, destination, (err: unknown): void => {
120138
if (err) logging.error(err);
121139
});
140+
122141
prompter.outro(chalk.bgGreen("File created successfully!"));
123142
}
124143
})
@@ -132,3 +151,5 @@ program
132151

133152
process.exit(0);
134153
});
154+
155+
// program.parse(process.argv);

0 commit comments

Comments
 (0)