Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 148c3c9

Browse files
committed
Handle unhandled promise rejections
1 parent 41287a8 commit 148c3c9

File tree

7 files changed

+23
-20
lines changed

7 files changed

+23
-20
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
## [2.0.3]
10+
### Fixed
11+
- Handle unhandled promise rejections
12+
913
## [2.0.2]
1014
### Fixed
1115
- Build executer's Docker images only when building tracers libraries

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@algorithm-visualizer/tracer-generator",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"description": "Visualization Libraries for Algorithm Visualizer",
55
"scripts": {
66
"build": "node ./node_modules/webpack/bin/webpack --bail --progress --config webpack.config.js && chmod +x ./bin/*"

src/common/util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import child_process from 'child_process';
44
const execute = (command, cwd, { stdout = process.stdout, stderr = process.stderr } = {}) => new Promise((resolve, reject) => {
55
if (!cwd) return reject(new Error('CWD Not Specified'));
66
const child = child_process.exec(command, { cwd }, (error, stdout, stderr) => {
7-
if (error) return reject(new Error(stderr));
7+
if (error) return reject(error.code ? new Error(stderr) : error);
88
resolve(stdout);
99
});
1010
if (stdout) child.stdout.pipe(stdout);
@@ -13,4 +13,4 @@ const execute = (command, cwd, { stdout = process.stdout, stderr = process.stder
1313

1414
export {
1515
execute,
16-
};
16+
};

src/executables/build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Promise from 'bluebird';
33

44
const { LANG } = process.env;
55
if (LANG) {
6-
languages[LANG].build();
6+
languages[LANG].build().catch(() => process.exit(1));
77
} else {
8-
Promise.each(Object.values(languages), language => language.build());
8+
Promise.each(Object.values(languages), language => language.build()).catch(() => process.exit(1));
99
}

src/executables/compile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import * as languages from '/languages';
22

33
const { LANG, TEMP_PATH } = process.env;
4-
languages[LANG].compile(TEMP_PATH);
4+
languages[LANG].compile(TEMP_PATH).catch(() => process.exit(1));

src/executables/release.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
import child_process from 'child_process';
21
import ghRelease from 'gh-release';
2+
import Promise from 'bluebird';
33
import { version } from '/package.json';
4+
import { execute } from '/common/util';
45

56
const { GITHUB_TOKEN } = process.env;
6-
ghRelease({
7-
owner: 'algorithm-visualizer',
8-
repo: 'tracers',
9-
auth: { token: GITHUB_TOKEN },
10-
}, err => {
11-
if (err) throw err;
12-
const docsProcess = child_process.exec([
7+
const release = Promise.promisify(ghRelease);
8+
9+
release({ owner: 'algorithm-visualizer', repo: 'tracers', auth: { token: GITHUB_TOKEN } })
10+
.catch(error => {
11+
console.error(error);
12+
throw error;
13+
})
14+
.then(() => execute([
1315
'rm -rf tracers.wiki',
1416
'git clone [email protected]:algorithm-visualizer/tracers.wiki.git',
1517
'rm tracers.wiki/*',
@@ -20,8 +22,5 @@ ghRelease({
2022
'git push origin master',
2123
'cd ..',
2224
'rm -rf tracers.wiki',
23-
].join(' && '), { cwd: __dirname });
24-
docsProcess.stdout.pipe(process.stdout);
25-
docsProcess.stderr.pipe(process.stderr);
26-
docsProcess.on('exit', process.exit);
27-
});
25+
].join(' && '), __dirname))
26+
.catch(() => process.exit(1));

src/executables/run.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import * as languages from '/languages';
22

33
const { LANG, TEMP_PATH } = process.env;
4-
languages[LANG].run(TEMP_PATH);
4+
languages[LANG].run(TEMP_PATH).catch(() => process.exit(1));

0 commit comments

Comments
 (0)