summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/configure.js26
-rw-r--r--package.json1
2 files changed, 9 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);
+
});
}
diff --git a/package.json b/package.json
index de4e4bf..5653622 100644
--- a/package.json
+++ b/package.json
@@ -34,6 +34,7 @@
"cheerio": "~0.17.0",
"colors": "~0.6.2",
"filesize": "~2.0.3",
+ "glob": "~4.0.2",
"inquirer": "~0.5.1",
"lodash": "~2.4.1",
"mkdirp": "~0.5.0",