Skip to content

Commit ff3a435

Browse files
authored
Build:util: await methods passed to Release.walk, test on Node 12
Changes: 1. Test on Node.js 12 instead of 10 2. Make `Release.walk` an async function, `await` each provided method. This makes it possible to easier integrate with asynchronous flows in various steps. 3. Throw on unhandled rejections, making jquery-release quit if any of the async steps passed to `Release.walk` ends up in a rejected state.
1 parent 1ef3335 commit ff3a435

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
language: node_js
22
node_js:
3-
- "10"
3+
- "12"

lib/util.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Release.define( {
5858
};
5959
},
6060

61-
walk: function( methods, fn ) {
61+
walk: async function( methods, fn ) {
6262
var method = methods.shift();
6363

6464
function next() {
@@ -70,10 +70,10 @@ Release.define( {
7070
}
7171

7272
if ( !method.length ) {
73-
method();
73+
await method();
7474
next();
7575
} else {
76-
method( next );
76+
await method( next );
7777
}
7878
}
7979
} );

release.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
"use strict";
44

5+
// Stop the release process if any of the asynchronous operations fails.
6+
process.on( "unhandledRejection", reason => {
7+
console.error( "Unhandled rejection:", reason );
8+
throw reason;
9+
} );
10+
511
var commonTasks, stableTasks,
612
fs = require( "fs" ),
713
Release = {

0 commit comments

Comments
 (0)