Skip to content

Commit

Permalink
fix(hip): Upgrade to node:8 (#9)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: No longer supports node:6, uses async/await
  • Loading branch information
philipjscott authored Apr 25, 2018
1 parent 5fc5fc1 commit 93d4b01
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
42 changes: 18 additions & 24 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,42 +115,36 @@ class ScmRouter extends Scm {

/**
* choose scm module
* @method chooseScm
* @async chooseScm
* @param {Object} config Configuration
* @param {String} config.scmContext Name of scm context
* @return {Promise} scm object
*/
chooseScm(config) {
return new Promise((resolve, reject) => {
if (config && typeof config.scmContext === 'string') {
const scm = this.scms[config.scmContext];
async chooseScm(config) {
if (config && typeof config.scmContext === 'string') {
const scm = this.scms[config.scmContext];

if (scm) {
return resolve(scm);
}
if (scm) {
return scm;
}
}

return reject(new Error('Not implemented'));
});
throw new Error('Not implemented');
}

/**
* Process by all scm module
* @method allScm
* @param {function(scm)} callback to return map
* @return {Promise} combined callback results
* Higher-order function that maps all scm modules and returns result
* @async allScm
* @param {function(scm)} fn function that maps an scm value
* @return {Promise} the mapped results of all scm values
*/
allScm(callback) {
return Promise.all(Object.keys(this.scms).map(key => callback(this.scms[key])))
.then((results) => {
let map = {};
async allScm(fn) {
const map = {};
const results = await Promise.all(Object.keys(this.scms).map(key => fn(this.scms[key])));

results.forEach((result) => {
map = Object.assign(map, result);
});
results.forEach(result => Object.assign(map, result));

return map;
});
return map;
}

/**
Expand Down Expand Up @@ -349,7 +343,7 @@ class ScmRouter extends Scm {
*/
_canHandleWebhook(headers, payload) {
return this.chooseWebhookScm(headers, payload)
.then(scm => !!scm)
.then(scm => Boolean(scm))
.catch(() => false);
}

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"Jeremiah Wuenschel <[email protected]>",
"Min Zhang <[email protected]>",
"Peter Peterson <[email protected]>",
"Philip Scott <[email protected]>",
"Reetika Rastogi <[email protected]>",
"St. John Johnson <[email protected]",
"Tiffany Kyi <[email protected]>"
Expand Down
2 changes: 1 addition & 1 deletion screwdriver.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
shared:
image: node:6
image: node:8

jobs:
main:
Expand Down

0 comments on commit 93d4b01

Please sign in to comment.