Skip to content

Commit

Permalink
fix: safe handling of missing env variables
Browse files Browse the repository at this point in the history
On Windows 7 the launcher will not load, throwing the error `Cannot read
property 'substr' of undefined`. This was caused by an undefined prefix
at `getAllPrefixes()`.

Closes #67
  • Loading branch information
LeonardoVal authored and dignifiedquire committed Dec 7, 2017
1 parent fe9d442 commit 98a4ada
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ var getAllPrefixes = function () {
var prefixes = [process.env.PROGRAMFILES, process.env['PROGRAMFILES(X86)']]
var prefix
for (var i = 0; i < prefixes.length; i++) {
for (var d = 0; d < drives.length; d += 1) {
prefix = drives[d] + prefixes[i].substr(1)
if (result.indexOf(prefix) === -1) {
result.push(prefix)
if (typeof prefixes[i] !== 'undefined') {
for (var d = 0; d < drives.length; d += 1) {
prefix = drives[d] + prefixes[i].substr(1)
if (result.indexOf(prefix) === -1) {
result.push(prefix)
}
}
}
}
Expand Down

0 comments on commit 98a4ada

Please sign in to comment.