Defaulting behaviour for empty git repos.
This commit is contained in:
parent
eae8ec97a9
commit
68a8a66bc7
|
@ -22,6 +22,24 @@ function checkInPlugin() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function askAboutTopLevel() {
|
||||||
|
const files = fs.readdirSync(process.cwd())
|
||||||
|
// we are in an empty git repo, don't ask
|
||||||
|
if (files.length === 1 && files[0] === ".git") {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
console.log(
|
||||||
|
info(`By default the plugin will be created in the directory "${name}"`)
|
||||||
|
)
|
||||||
|
console.log(
|
||||||
|
info(
|
||||||
|
"if you are already in an empty directory, such as a new Git repo, you can disable this functionality."
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return questions.confirmation("Create top level directory?")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function init(opts) {
|
async function init(opts) {
|
||||||
const type = opts["init"] || opts
|
const type = opts["init"] || opts
|
||||||
if (!type || !PLUGIN_TYPE_ARR.includes(type)) {
|
if (!type || !PLUGIN_TYPE_ARR.includes(type)) {
|
||||||
|
@ -45,15 +63,7 @@ async function init(opts) {
|
||||||
`An amazing Budibase ${type}!`
|
`An amazing Budibase ${type}!`
|
||||||
)
|
)
|
||||||
const version = await questions.string("Version", "1.0.0")
|
const version = await questions.string("Version", "1.0.0")
|
||||||
console.log(
|
const topLevel = await askAboutTopLevel()
|
||||||
info(`By default the plugin will be created in the directory "${name}"`)
|
|
||||||
)
|
|
||||||
console.log(
|
|
||||||
info(
|
|
||||||
"if you are already in an empty directory, such as a new Git repo, you can disable this functionality."
|
|
||||||
)
|
|
||||||
)
|
|
||||||
const topLevel = await questions.confirmation("Create top level directory?")
|
|
||||||
// get the skeleton
|
// get the skeleton
|
||||||
console.log(info("Retrieving project..."))
|
console.log(info("Retrieving project..."))
|
||||||
await getSkeleton(type, name)
|
await getSkeleton(type, name)
|
||||||
|
|
Loading…
Reference in New Issue