htmv 0.0.17 → 0.0.18-beta-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "htmv",
3
3
  "main": "dist/index.js",
4
4
  "type": "module",
5
- "version": "0.0.17",
5
+ "version": "0.0.18-beta-1",
6
6
  "devDependencies": {
7
7
  "@biomejs/biome": "2.3.3",
8
8
  "@types/bun": "latest"
@@ -23,10 +23,12 @@ export default async (args: string[]) => {
23
23
  <h1>This view was quickly generated with htmv gen.</h1>
24
24
  </body>
25
25
  </html>`;
26
- await generateFile(
27
- path.join(viewsFolderPath, `${name}.html`),
28
- viewsContents,
29
- );
26
+ const fileName = `${name}.html`;
27
+ const filePath = path.join(viewsFolderPath, fileName);
28
+ const fileAlreadyExists = await exists(filePath);
29
+ if (fileAlreadyExists)
30
+ return console.error(`File ${fileName} already exists.`);
31
+ await generateFile(filePath, viewsContents);
30
32
  }
31
33
  if (type.toLowerCase() === "route") {
32
34
  const routesFolderPath = await validateOptions("routes", ...options);
@@ -40,10 +42,13 @@ export function POST (_params: RouteParams) {
40
42
  return "Searching for something more specific? How about a POST method route?"
41
43
  };
42
44
  `;
43
- await generateFile(
44
- path.join(routesFolderPath, `${name}.ts`),
45
- routeContents,
46
- );
45
+ const fileName = `${name}.ts`;
46
+ const filePath = path.join(routesFolderPath, fileName);
47
+ const fileAlreadyExists = await exists(filePath);
48
+
49
+ if (fileAlreadyExists)
50
+ return console.error(`File ${fileName} already exists.`);
51
+ await generateFile(filePath, routeContents);
47
52
  }
48
53
  console.log(`${type} ${name} generated succesfully.`);
49
54
  };