Skip to content

Commit 46cc382

Browse files
committed
Merge pull request mllrsohn#29 from rogierschouten/requireresolve
Use require.resolve() instead of manual search for protractor .bin dir
2 parents e849ae8 + f452096 commit 46cc382

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

index.js

+6-18
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,19 @@ var async = require('async');
66
var PluginError = require('gulp-util').PluginError;
77
var winExt = /^win/.test(process.platform)?".cmd":"";
88

9-
109
// optimization: cache for protractor binaries directory
1110
var protractorDir = null;
1211

1312
function getProtractorDir() {
1413
if (protractorDir) {
1514
return protractorDir;
1615
}
17-
18-
// how deep are we wrt filesystem root?
19-
var cwd = path.resolve(".");
20-
var depth = /^win/.test(process.platform) ? cwd.match(/\\/g).length : cwd.match(/\//g).length;
21-
depth = depth - 1;
22-
23-
var result = __dirname + "/node_modules";
24-
var count = 0;
25-
while (count <= depth)
26-
{
27-
if (fs.existsSync(path.resolve(result + "/.bin/protractor")))
28-
{
29-
protractorDir = result + "/.bin";
30-
return path.normalize(protractorDir);
31-
}
32-
result = "../" + result;
33-
count++;
16+
var result = require.resolve("protractor");
17+
if (result) {
18+
// result is now something like
19+
// c:\\Source\\gulp-protractor\\node_modules\\protractor\\lib\\protractor.js
20+
protractorDir = path.resolve(path.join(path.dirname(result), "..", "..", ".bin"));
21+
return protractorDir;
3422
}
3523
throw new Error("No protractor installation found.");
3624
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gulp-protractor",
3-
"version": "0.0.9",
3+
"version": "0.0.10",
44
"description": "A helper for protactor and gulp",
55
"keywords": [
66
"gulpfriendly",

0 commit comments

Comments
 (0)