Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
fix: test condition need a cb
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed May 27, 2019
1 parent 62833e9 commit 8b7435a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions bin/switcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@ function nvmCommand (maxSatisfyVersion, currentVersion) {

function createSwitcher (maxSatisfyVersion, currentVersion) {
var binaries = {
nvm: {
cmd: process.env.SHELL,
args: ['-c', 'source $NVM_DIR/nvm.sh; ' + nvmCommand(maxSatisfyVersion, currentVersion)]
},

n: {
cmd: 'n',
args: [maxSatisfyVersion]
},
nvm: {
cmd: process.env.SHELL,
args: ['-c', 'source $NVM_DIR/nvm.sh; ' + nvmCommand(maxSatisfyVersion, currentVersion)]
}
}

return {
getBin: function (cb) {
var binariesNames = Object.keys(binaries)
var index = 0
var bin

function getBin (next) {
var binName = binariesNames.pop()
function getBin (cb) {
var binName = binariesNames[index++]
which(binName, function (err) {
if (!err) bin = binName
return next()
return cb()
})
}

function whileCondition () {
return !bin && binariesNames.length !== 0
function test (cb) {
return cb(null, !bin && index < binariesNames.length)
}

doWhilst(getBin, whileCondition, function (err) {
doWhilst(getBin, test, function (err) {
return cb(err, bin)
})
},
Expand Down

0 comments on commit 8b7435a

Please sign in to comment.