@@ -203,12 +203,13 @@ const initFunction = async () => {
203
203
}
204
204
205
205
const functionId = answers.id === 'unique()' ? ID.unique() : answers.id;
206
- const functionDir = path.join(functionFolder, functionId);
206
+ const functionName = answers.name;
207
+ const functionDir = path.join(functionFolder, functionName);
207
208
const templatesDir = path.join(functionFolder, `${functionId}-templates`);
208
209
const runtimeDir = path.join(templatesDir, answers.runtime.name);
209
210
210
211
if (fs.existsSync(functionDir)) {
211
- throw new Error(`( ${functionId } ) already exists in the current directory. Please choose another name.`);
212
+ throw new Error(`( ${functionName } ) already exists in the current directory. Please choose another name.`);
212
213
}
213
214
214
215
if (!answers.runtime.entrypoint) {
@@ -285,7 +286,7 @@ const initFunction = async () => {
285
286
286
287
fs.rmSync(templatesDir, { recursive: true, force: true });
287
288
288
- const readmePath = path.join(process.cwd(), 'functions', functionId , 'README.md');
289
+ const readmePath = path.join(process.cwd(), 'functions', functionName , 'README.md');
289
290
const readmeFile = fs.readFileSync(readmePath).toString();
290
291
const newReadmeFile = readmeFile.split('\n');
291
292
newReadmeFile[0] = `# ${answers.name}`;
@@ -306,7 +307,7 @@ const initFunction = async () => {
306
307
entrypoint: answers.runtime.entrypoint || '',
307
308
commands: answers.runtime.commands || '',
308
309
ignore: answers.runtime.ignore || null,
309
- path: `functions/${functionId }`,
310
+ path: `functions/${functionName }`,
310
311
};
311
312
312
313
localConfig.addFunction(data);
0 commit comments