@guchen_0521/create-temp 0.1.1 → 0.1.2
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/bin/cli.js +1 -1
- package/lib/scaffold.js +12 -1
- package/package.json +1 -1
package/bin/cli.js
CHANGED
package/lib/scaffold.js
CHANGED
|
@@ -90,6 +90,16 @@ function formatTemplateKey(projectRoot, templateDir) {
|
|
|
90
90
|
.join("/");
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
function normalizeTemplateKey(templateKey) {
|
|
94
|
+
if (!templateKey) {
|
|
95
|
+
return templateKey;
|
|
96
|
+
}
|
|
97
|
+
return templateKey
|
|
98
|
+
.trim()
|
|
99
|
+
.replaceAll("\\", "/")
|
|
100
|
+
.replace(/^\.\/+/, "");
|
|
101
|
+
}
|
|
102
|
+
|
|
93
103
|
async function promptSelectTemplate(templates) {
|
|
94
104
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
95
105
|
console.log("Available templates:");
|
|
@@ -195,8 +205,9 @@ export async function scaffold({ templateKey, targetDir }) {
|
|
|
195
205
|
|
|
196
206
|
let selectedTemplate = null;
|
|
197
207
|
if (templateKey) {
|
|
208
|
+
const normalizedKey = normalizeTemplateKey(templateKey);
|
|
198
209
|
selectedTemplate = templates.find(
|
|
199
|
-
(template) => template.key ===
|
|
210
|
+
(template) => normalizeTemplateKey(template.key) === normalizedKey
|
|
200
211
|
);
|
|
201
212
|
if (!selectedTemplate) {
|
|
202
213
|
const keys = templates.map((template) => template.key).join(", ");
|