Skip to content

Commit a691bc0

Browse files
committed
Prompt for global variable name
1 parent cb132ca commit a691bc0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ async function init() {
8383
const unscopedPackageName = scopedPackageName.replace(/.*\//, '')
8484
const shortUnscopedPackageName = unscopedPackageName.replace(/^vue-/, '')
8585
const projectName = unscopedPackageName.replace(/-+/g, ' ').trim().split(' ').map(s => s[0].toUpperCase() + s.slice(1)).join(' ')
86-
const globalVariableName = projectName.replace(/ /g, '')
8786

8887
const targetDirName = await textPrompt('Target directory', unscopedPackageName)
8988

@@ -112,6 +111,13 @@ async function init() {
112111
process.exit(1)
113112
}
114113

114+
const globalVariableName = await textPrompt('Global variable name', projectName.replace(/ /g, ''))
115+
116+
if (!/^[a-zA-Z$_][\w$]*$/.test(globalVariableName)) {
117+
console.log('Invalid variable name: ' + globalVariableName)
118+
process.exit(1)
119+
}
120+
115121
const githubPath = await textPrompt('GitHub path, e.g. skirtles-code/test-project (optional)')
116122

117123
if (githubPath && !/^[\w-]+\/[\w-]+$/.test(githubPath)) {

0 commit comments

Comments
 (0)