diff options
author | przemyslawpluta <przemekpluta@hotmail.com> | 2014-06-16 22:39:05 +0100 |
---|---|---|
committer | przemyslawpluta <przemekpluta@hotmail.com> | 2014-06-16 22:39:05 +0100 |
commit | bec24a24b4c020469b1f5ed2e0ec7822f9266da7 (patch) | |
tree | 936e8bc2c90f5c8a34f917f5c33992c7938029af /lib/configure.js | |
parent | 37ee2a8545f3ef36ef70feb3c20e208f70bcb4aa (diff) | |
download | mongo-edu-bec24a24b4c020469b1f5ed2e0ec7822f9266da7.zip |
update py scan
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); + }); } |