Skip to content

Commit

Permalink
feat(heroku): provide prompt to set the deployment region
Browse files Browse the repository at this point in the history
  • Loading branch information
balthazar committed Jul 24, 2014
1 parent cb866d1 commit 13cd5e7
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions heroku/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ Generator.prototype.askForName = function askForName() {
}.bind(this));
};

Generator.prototype.askForRegion = function askForRegion() {
var done = this.async();

var prompts = [{
type: "list",
name: 'region',
message: 'On which region do you want to deploy ?',
choices: [ "US", "EU"],
default: 0
}];

this.prompt(prompts, function (props) {
this.region = props.region.toLowerCase();
done();
}.bind(this));
};

Generator.prototype.checkInstallation = function checkInstallation() {
if(this.abort) return;
var done = this.async();
Expand Down Expand Up @@ -65,9 +82,10 @@ Generator.prototype.gitInit = function gitInit() {
Generator.prototype.herokuCreate = function herokuCreate() {
if(this.abort) return;
var done = this.async();
var regionParams = (this.region !== 'us') ? ' --region ' + this.region : '';

this.log(chalk.bold('Creating heroku app and setting node environment'));
var child = exec('heroku apps:create ' + this.deployedName + ' && heroku config:set NODE_ENV=production', { cwd: 'dist' }, function (err, stdout, stderr) {
var child = exec('heroku apps:create ' + this.deployedName + regionParams + ' && heroku config:set NODE_ENV=production', { cwd: 'dist' }, function (err, stdout, stderr) {
if (err) {
this.abort = true;
this.log.error(err);
Expand Down Expand Up @@ -182,4 +200,4 @@ Generator.prototype.gitForcePush = function gitForcePush() {
child.stdout.on('data', function(data) {
this.log(data.toString());
}.bind(this));
};
};

0 comments on commit 13cd5e7

Please sign in to comment.