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

Able to select project with name #127

Merged
merged 3 commits into from
Aug 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 38 additions & 6 deletions components/projects/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,45 @@ export default class Project {
}
}

public async select() {
const chosen = await this.choose()
if (chosen) {
this.helper.setProp("projectId", chosen.id);
this.helper.setProp("projectName", chosen.name);
console.log(colors.green(`Project "${ chosen.name }" (${ chosen.id }) is successfully selected`));
public async select(projectName?: string) {
let chosen: any;
if (typeof projectName === "string") {
chosen = await this.getDataByName(projectName);
if (chosen !== undefined) {
// project name found
this.helper.setProp("projectId", chosen.id);
this.helper.setProp("projectName", chosen.name);
} else {
// project name not found, select through inquirer
console.log(
`Project with name ${colors.green(projectName)} is not found. ` +
`Please choose listed project name below:`);
chosen = await this.choose()
if (chosen) {
this.helper.setProp("projectId", chosen.id);
this.helper.setProp("projectName", chosen.name);
}
}
} else {
// projectName is empty
chosen = await this.choose()
if (chosen) {
this.helper.setProp("projectId", chosen.id);
this.helper.setProp("projectName", chosen.name);
}
}
console.log(colors.green(`Project "${ chosen.name }" (${ chosen.id }) is successfully selected`));

if (!chosen || chosen === undefined) {
chosen = await this.choose()
if (chosen) {
this.helper.setProp("projectId", chosen.id);
this.helper.setProp("projectName", chosen.name);
console.log(colors.green(`Project "${ chosen.name }" (${ chosen.id }) is successfully selected`));
}
}


}

public async delete(projectName?: string) {
Expand Down
42 changes: 36 additions & 6 deletions lib/components/projects/project.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.