Skip to content

Commit

Permalink
Update the command to use getProjectId()
Browse files Browse the repository at this point in the history
  • Loading branch information
TrCaM committed Jul 8, 2019
1 parent c5f4cd7 commit 691dae1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
14 changes: 2 additions & 12 deletions src/commands/apps-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as clc from "cli-color";
import * as ora from "ora";

import * as Command from "../command";
import * as getProjectId from "../getProjectId";
import * as FirebaseError from "../error";
import { AppPlatform, createAndroidApp, createIosApp, createWebApp } from "../appsCreate";
import { prompt, promptOnce, Question } from "../prompt";
Expand Down Expand Up @@ -157,11 +158,6 @@ module.exports = new Command("apps:create [platform] [displayName]")
"[platform] IOS, ANDROID or WEB\n" +
"[displayName] the display name of the app"
)
.option(
"-p, --project <projectId>",
"ID of the Firebase project under which new app is registered " +
"(default to the Firebase project of the current directory)."
)
.option("-a, --package-name <packageName>", "required package name for the Android app")
.option("-b, --bundle-id <bundleId>", "required bundle id for the iOS app")
.option("-s, --app-store-id <appStoreId>", "(optional) app store id for the iOS app")
Expand All @@ -172,13 +168,7 @@ module.exports = new Command("apps:create [platform] [displayName]")
displayName: string | undefined,
options: any
): Promise<any> => {
if (!options.project) {
throw new FirebaseError(
"No Firebase project detected.\n" +
"Please run the command inside an existing Firebase project directory " +
"or use --project option."
);
}
const projectId = getProjectId(options);

if (!options.nonInteractive && !platform) {
platform = await promptOnce({
Expand Down
2 changes: 1 addition & 1 deletion src/getProjectId.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var FirebaseError = require("./error");
* is required
* @returns {String} The firebase name
*/
module.exports = function(options, allowNull) {
module.exports = function(options, allowNull = false) {
if (!options.project && !allowNull) {
var aliases = _.get(options, "rc.projects", {});
var aliasCount = _.size(aliases);
Expand Down

0 comments on commit 691dae1

Please sign in to comment.