Skip to content

Commit

Permalink
add vsc namespace prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
huygn committed Aug 15, 2018
1 parent c8d1051 commit a7c6165
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions sao.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ module.exports = {
gitInit: false,
installDependencies: false,
prompts: {
namespace: {
message: 'What is your vsc namespace?',
default: 'dwarvesf',
},
domain: {
message: 'What is your vsc domain?',
default: 'github.com',
Expand All @@ -18,15 +22,24 @@ module.exports = {
default: `my ${superb()} Go project`,
},
},
data({ domain }) {
data({ domain, namespace }) {
return {
domainDir: domain + '/',
domainDir: `${domain}/${namespace}/`,
}
},
move: {
gitignore: '.gitignore',
},
post({ answers, folderName, folderPath, log, chalk }, stream) {
post(
{
answers: { domain, namespace },
folderName,
folderPath,
log,
chalk,
},
stream
) {
// check for GOPATH env
if (!process.env.GOPATH) {
log.error(
Expand All @@ -37,7 +50,7 @@ module.exports = {
process.exit(1)
}
// check if same project src already exist
const srcPath = `${process.env.GOPATH}/src/${answers.domain}`
const srcPath = `${process.env.GOPATH}/src/${domain + '/' + namespace}`
const projectPath = `${srcPath}/${folderName}`
if (fs.existsSync(projectPath)) {
log.error(
Expand Down

0 comments on commit a7c6165

Please sign in to comment.