Skip to content

Commit 5f7bca2

Browse files
committed
Automatically use alias if only one present. (#152)
1 parent c329357 commit 5f7bca2

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

commands/use.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ var listAliases = function(options) {
3232
logger.info(' ' + listing);
3333
}
3434
});
35-
} else {
36-
logger.info('Run', chalk.bold('firebase use --add'), 'to define a new project alias.');
35+
logger.info();
3736
}
37+
logger.info('Run', chalk.bold('firebase use --add'), 'to define a new project alias.');
3838
};
3939

4040
var verifyMessage = function(name) {

lib/command.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,14 @@ Command.prototype.applyRC = function(options) {
143143
options.project = options.config.defaults.project;
144144
}
145145

146-
var rcProject = _.get(rc, ['projects', options.project]);
146+
var aliases = rc.projects || {};
147+
var rcProject = _.get(aliases, options.project);
147148
if (rcProject) {
148149
options.projectAlias = options.project;
149150
options.project = rcProject;
151+
} else if (_.size(aliases) === 1) {
152+
options.projectAlias = _.head(_.keys(aliases));
153+
options.project = _.head(_.values(aliases));
150154
}
151155
};
152156

lib/getProjectId.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ module.exports = function(options, allowNull) {
2323
throw new FirebaseError('No project active. Run with ' + chalk.bold('--project <projectId>') + ' or define an alias by\nrunning ' + chalk.bold('firebase use --add'), {
2424
exit: 1
2525
});
26-
} else if (aliasCount === 1) {
27-
var name = _.head(_.keys(aliases));
28-
throw new FirebaseError('No project active, but a project alias is available.\n\nRun ' + chalk.bold('firebase use ' + name) + ' to activate project ' + chalk.bold(aliases[name]));
2926
} else {
3027
var aliasList = _.map(aliases, function(projectId, aname) {
3128
return ' ' + aname + ' (' + projectId + ')';

0 commit comments

Comments
 (0)