diff options
Diffstat (limited to 'lib/configure.js')
-rw-r--r-- | lib/configure.js | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/lib/configure.js b/lib/configure.js index 9a5696a..47c5245 100644 --- a/lib/configure.js +++ b/lib/configure.js @@ -6,9 +6,8 @@ * https://github.com/przemyslawpluta/mongo-edu/blob/master/LICENSE */ -var fs = require('fs'), - path = require('path'), - which = require('which'); +var which = require('which'), + glob = require('glob'); module.exports = function configure(argv, callback) { @@ -21,10 +20,8 @@ module.exports = function configure(argv, callback) { which(python, function whichTest(err) { if (err !== null) { - //console.log('`which` failed', python, err); if (isWin) { guessPython(); } else { failNoPython(); } } else { - //console.log('`which` succeeded', python, execPath); process.env.PYTHON = python; callback(null); } @@ -33,23 +30,16 @@ module.exports = function configure(argv, callback) { function guessPython() { - console.log('Could not find "' + python + '". guessing location'); + glob('\\Python**\\python.exe', function find(err, files) { - var rootDir = process.env.SystemDrive || 'C:\\', pythonPath; + if (err !== null) { return callback(err); } - if (rootDir[rootDir.length - 1] !== '\\') { rootDir += '\\'; } + if (!files.length) { return failNoPython(); } - pythonPath = path.resolve(rootDir, 'Python27', 'python.exe'); - console.log('ensuring that file exists:', pythonPath); - - fs.stat(pythonPath, function stat(err) { - if (err !== null) { - if (err.code === 'ENOENT') { failNoPython(); } else { callback(err); } - return; - } - python = pythonPath; - process.env.PYTHON = pythonPath; + python = files.shift(); + process.env.PYTHON = python; callback(null); + }); } |