Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #14 from Financial-Times/issue-13
Browse files Browse the repository at this point in the history
Should have a non-zero exit status if command invalid — fixes #13
  • Loading branch information
matthew-andrews committed Mar 5, 2015
2 parents 6b5786e + 1166519 commit 5946698
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 41 deletions.
14 changes: 0 additions & 14 deletions .editorconfig

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
script: npm test
node_js:
- '0.10'
- '0.12'
before_deploy:
- npm-prepublish --verbose
deploy:
Expand Down
13 changes: 12 additions & 1 deletion bin/next-build-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var provision = require('../tasks/provision');
var downloadConfiguration = require('../tasks/download-configuration');

function list(val) {
return val.split(',');
return val.split(',');
}

function exit(err) {
Expand Down Expand Up @@ -66,4 +66,15 @@ program
}
});

program
.command('*')
.description('')
.action(function(app) {
exit("The command ‘" + app + "’ is not known");
});

program.parse(process.argv);

if (!process.argv.slice(2).length) {
program.outputHelp();
}
1 change: 1 addition & 0 deletions lib/heroku-auth-token.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*jshint node:true*/
'use strict';

var denodeify = require('denodeify');
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
"next-build-tools": "./bin/next-build-tools.js"
},
"scripts": {
"test": "jshint `find . -name '*.js' ! -path './node_modules/*'`"
"test": "origami-build-tools verify"
},
"dependencies": {
"commander": "^2.6.0",
"debug": "^2.1.1",
"denodeify": "^1.2.0",
"es6-promise": "^2.0.1",
"haikro": "^1.12.0",
"haikro": "^1.9.0",
"heroku-client": "^1.9.1",
"fetchres": "^1.0.4",
"haikro": "^1.9.0",
"isomorphic-fetch": "^1.1.0"
},
"devDependencies": {
"jshint": "^2.6.0",
"npm-prepublish": "^1.2.0"
"npm-prepublish": "^1.2.0",
"origami-build-tools": "^2.10.0"
}
}
1 change: 1 addition & 0 deletions tasks/clean.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*jshint node:true*/
'use strict';

var denodeify = require('denodeify');
Expand Down
12 changes: 7 additions & 5 deletions tasks/configure.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/*jshint node:true*/
/*global fetch*/
'use strict';

var packageJson = require(process.cwd() + '/package.json');
Expand All @@ -6,12 +8,12 @@ var normalizeName = require('../lib/normalize-name');
var fetchres = require('fetchres');

module.exports = function(opts) {

var source = opts.source || 'ft-next-' + normalizeName(packageJson.name);
var target = opts.target || source;
var overrides = {};

if (opts.overrides) {
if (opts.overrides) {
opts.overrides.map(function (o) {
var t = o.split('=');
overrides[t[0]] = t[1];
Expand Down Expand Up @@ -58,7 +60,7 @@ module.exports = function(opts) {
Object.keys(desired).forEach(function(key) {
patch[key] = desired[key];
});

Object.keys(overrides).forEach(function(key) {
patch[key] = overrides[key];
});
Expand All @@ -70,9 +72,9 @@ module.exports = function(opts) {
console.log("Setting config var: " + key);
}
});

console.log("Setting environment to", patch);

return fetch('https://api.heroku.com/apps/' + target + '/config-vars', {
headers: authorizedPostHeaders,
method: 'patch',
Expand Down
1 change: 1 addition & 0 deletions tasks/deploy.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*jshint node:true*/
"use strict";

var packageJson = require(process.cwd() + '/package.json');
Expand Down
2 changes: 2 additions & 0 deletions tasks/download-configuration.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/*jshint node:true*/
/*global fetch*/
'use strict';

var herokuAuthToken = require('../lib/heroku-auth-token');
Expand Down
28 changes: 13 additions & 15 deletions tasks/provision.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
/*jshint node:true*/
'use strict';

var debug = require('debug')('next-build-tools');
var packageJson = require(process.cwd() + '/package.json');
var denodeify = require('denodeify');
var exec = denodeify(require('child_process').exec, function(err, stdout, stderr) { return [err, stdout]; });
var create = require('haikro/lib/create');
var logger = require('haikro/lib/logger');
var normalizeName = require('../lib/normalize-name');

// create a Heroku application server
module.exports = function (name) {
var heroku_auth = process.env.HEROKU_AUTH_TOKEN;

var heroku_auth = process.env.HEROKU_AUTH_TOKEN;

if (!heroku_auth) {
throw "You need to set a HEROKU_AUTH_TOKEN environment variables";
}
if (!heroku_auth) {
throw "You need to set a HEROKU_AUTH_TOKEN environment variables";
}

var token;
return Promise.all([
process.env.HEROKU_AUTH_TOKEN ? Promise.resolve(process.env.HEROKU_AUTH_TOKEN) : exec('heroku auth:token'),
])
.then(function(results) {
logger.setLevel('debug');
logger.setLevel('debug');
token = results[0].trim();
var server = {
app: name,
region: 'eu',
var server = {
app: name,
region: 'eu',
token: token,
organization: 'financial-times'
};
return create(server);
organization: 'financial-times'
};
return create(server);
});
};

0 comments on commit 5946698

Please sign in to comment.