Skip to content

Commit d7ddb30

Browse files
committed
Wrap Atom's code to try/catch block
1 parent bf788dd commit d7ddb30

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/installer/helpers.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ function fileExistsAndSizeMatches(target, contentLength) {
6363

6464
async function _download(source, target) {
6565
let proxy = null;
66-
if (atom) {
66+
try {
67+
const apmPath = atom.packages.getApmPath();
6768
proxy = await new Promise((resolve, reject) => {
6869
runCommand(
69-
[atom.packages.getApmPath(), '--no-color', 'config', 'get', 'https-proxy'],
70+
[apmPath, '--no-color', 'config', 'get', 'https-proxy'],
7071
(code, stdout) => {
7172
if (code !== 0) {
7273
return reject(null);
@@ -75,9 +76,9 @@ async function _download(source, target) {
7576
}
7677
);
7778
});
78-
} else {
79+
} catch (err) {
7980
proxy = (process.env.HTTPS_PROXY && process.env.HTTPS_PROXY.trim()
80-
|| process.env.HTTP_PROXY && process.env.HTTP_PROXY.trim());
81+
|| process.env.HTTP_PROXY && process.env.HTTP_PROXY.trim());
8182
}
8283
return new Promise((resolve, reject) => {
8384
const file = fs.createWriteStream(target);

0 commit comments

Comments
 (0)