From 13cd5e7d42f2845268f38ba19e0d253ae675c594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aper=C3=A7u?= Date: Thu, 24 Jul 2014 21:29:03 +0200 Subject: [PATCH] feat(heroku): provide prompt to set the deployment region --- heroku/index.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/heroku/index.js b/heroku/index.js index a7b23cbb5..bd46a86a4 100644 --- a/heroku/index.js +++ b/heroku/index.js @@ -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(); @@ -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); @@ -182,4 +200,4 @@ Generator.prototype.gitForcePush = function gitForcePush() { child.stdout.on('data', function(data) { this.log(data.toString()); }.bind(this)); -}; \ No newline at end of file +};