Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #356 #614

Merged
merged 2 commits into from
Jun 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 31 additions & 18 deletions packages/workbox-cli/src/lib/questions/ask-root-of-web-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,38 @@ module.exports = () => {
});
})
.then((subdirectories) => {
const choices = subdirectories.concat([
new inquirer.Separator(),
manualEntryChoice,
]);
return inquirer.prompt([
{
name: 'rootDir',
message: 'What is the root of your web app?',
type: 'list',
choices: choices,
},
{
name: 'rootDir',
message: 'Please manually enter the root of your web app?',
when: (answers) => {
return answers.rootDir === manualEntryChoice;
if (subdirectories.length > 0) {
// There are subdirectories we can set for the root of the project.
const choices = subdirectories.concat([
new inquirer.Separator(),
manualEntryChoice,
]);
return inquirer.prompt([
{
name: 'rootDir',
message: 'What is the root of your web app?',
type: 'list',
choices: choices,
},
},
]);
{
name: 'rootDir',
message: 'Please manually enter the root of your web app?',
when: (answers) => {
return answers.rootDir === manualEntryChoice;
},
},
]);
} else {
// There are no subdirectories so the developer must manually define this.
return inquirer.prompt([
{
name: 'rootDir',
message: 'Please enter the root of your web app? (Defaults to ' +
'the current directory)',
default: '.',
},
]);
}
})
.then((answers) => {
return path.join(currentDirectory, answers.rootDir);
Expand Down