jelement-cli
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -23,27 +23,19 @@ #!/usr/bin/env node | ||
function init() { | ||
inputComponentName() | ||
.then(nameAnswer => { | ||
if (nameAnswer.component) { | ||
compontName = uppercamelcase(nameAnswer.component) | ||
inputComponentPath() | ||
.then(pathAnswer => { | ||
const targetPath = path.join(cwd, pathAnswer.path || './') | ||
to = path.resolve(targetPath, `${compontName}.vue`) | ||
if (fs.existsSync(to)) { | ||
componentExistHandler(compontName) | ||
.then(existAnswer => { | ||
if (existAnswer.ok) { | ||
handleTemplate() | ||
} | ||
}) | ||
} else { | ||
handleTemplate() | ||
} | ||
}) | ||
} else { | ||
console.log(chalk.bgRed('[组件名]必填 - Please enter the component file name')) | ||
process.exit(1); | ||
} | ||
}) | ||
async function init() { | ||
const { component } = await inputComponentName() | ||
if (component) { | ||
compontName = uppercamelcase(component) | ||
const pathAnswer = await inputComponentPath() | ||
const targetPath = path.join(cwd, pathAnswer.path || './') | ||
to = path.resolve(targetPath, `${compontName}.vue`) | ||
if (fs.existsSync(to)) { | ||
const { ok } = await componentExistHandler(compontName) | ||
if (ok) handleTemplate() | ||
} else { | ||
handleTemplate() | ||
} | ||
} else { | ||
console.log(chalk.bgRed('[组件名]必填 - Please enter the component file name')) | ||
process.exit(1); | ||
} | ||
} | ||
@@ -106,20 +98,16 @@ | ||
function selectTemplate() { | ||
return selectBaseType() | ||
.then(answer => { | ||
return accordingToSpecificTemplate(answer.selected) | ||
}) | ||
async function selectTemplate() { | ||
const { selected } = await selectBaseType() | ||
return accordingToSpecificTemplate(selected) | ||
} | ||
function handleTemplate() { | ||
selectTemplate() | ||
.then(answer => { | ||
const templatePath = path.resolve(__dirname, '../template', answer.path) | ||
const content = fs.readFileSync(templatePath, 'utf8') | ||
write(to, content) | ||
console.log(chalk.green('模板已生成...')) | ||
console.log(chalk.green(`生成路径: ${to}`)) | ||
}) | ||
async function handleTemplate() { | ||
const answer = await selectTemplate() | ||
const templatePath = path.resolve(__dirname, '../template', answer.path) | ||
const content = fs.readFileSync(templatePath, 'utf8') | ||
write(to, content) | ||
console.log(chalk.green('模板已生成...')) | ||
console.log(chalk.green(`生成路径: ${to}`)) | ||
} | ||
module.exports = init |
{ | ||
"name": "jelement-cli", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "preferGlobal": true, |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
6679
98