hono-router
Advanced tools
Comparing version 1.0.4 to 1.0.5
24
index.js
@@ -57,3 +57,3 @@ #!/usr/bin/env node | ||
*/ | ||
const generateRoutes = (dir, out) => { | ||
const generateRoutes = (dir, out, isDeno) => { | ||
/** @type {string[]} */ | ||
@@ -74,5 +74,7 @@ const imports = []; | ||
const entryPath = path.join(currentPath, entry.name); | ||
const importPath = path | ||
let importPath = path | ||
.join(basePath, entry.name) | ||
.replace(/\.(ts|tsx)$/, ''); | ||
if (!isDeno){ | ||
importPath = importPath.replace(/\.(ts|tsx)$/, ''); | ||
} | ||
if (entry.isDirectory()) { | ||
@@ -92,3 +94,3 @@ traverseDirectories(entryPath, importPath); | ||
.replace(/\[(.+?)\]/g, '$1'); // Ensure valid variable names | ||
const importPathString = importPath.replace(/index$/, ''); | ||
const importPathString = isDeno ? importPath : importPath.replace(/index$/, ''); | ||
const relativePath = path | ||
@@ -165,3 +167,11 @@ .relative(path.dirname(out), path.join(dir, importPathString)) | ||
const [routesDir, outputFile] = process.argv.slice(2); | ||
const args = process.argv.slice(2); | ||
const denoFlagIndex = args.indexOf('--deno'); | ||
const isDeno = denoFlagIndex !== -1; | ||
if (isDeno) { | ||
args.splice(denoFlagIndex, 1); // Remove the --deno flag from the arguments | ||
} | ||
const [routesDir, outputFile] = args; | ||
if (!routesDir || !outputFile) { | ||
@@ -177,3 +187,3 @@ console.error( | ||
// Initial generation | ||
generateRoutes(routesDir, outputFile); | ||
generateRoutes(routesDir, outputFile, isDeno); | ||
@@ -187,3 +197,3 @@ // Watch mode | ||
); | ||
generateRoutes(routesDir, outputFile); | ||
generateRoutes(routesDir, outputFile, isDeno); | ||
}); |
{ | ||
"name": "hono-router", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "hotloading script to generate file-based routing config for Hono", | ||
@@ -5,0 +5,0 @@ "author": "Stu Kennedy", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9816
220