diff --git a/lib/html-snapshots.js b/lib/html-snapshots.js
index 884d1947..e3d62493 100644
--- a/lib/html-snapshots.js
+++ b/lib/html-snapshots.js
@@ -3,7 +3,7 @@
*
* Produce html snapshots using for a website for SEO purposes.
* This is required for javascript SPAs or ajax page output.
- * By default, uses a selector to search content to determine if
+ * By default, uses a selector to search content to determine if
* a page is "ready" for its html snapshot.
*
* Copyright (c) 2013, 2014, Alex Grant, LocalNerve, contributors
@@ -20,15 +20,33 @@ var inputFactory = require("./input-generators");
var async = require("./async");
var phantomDir = "./phantom";
var snapshotScript = path.join(phantomDir, "default.js");
-var phantomJS = "../node_modules/.bin/phantomjs" +
- (process.platform === "win32" ? ".cmd" : "");
+
+/**
+ * Determine the default phantomJS module path. This is overridden by the
+ * phatomjs option.
+ *
+ * Technique (and concerns) from karma-phantomjs-launcher (MIT).
+ */
+var defaultPhantomJSExePath = function () {
+ // If the path we're given by phantomjs is to a .cmd, it is pointing to a global copy.
+ // Using the cmd as the process to execute causes problems cleaning up the processes
+ // so we walk from the cmd to the phantomjs.exe and use that instead.
+
+ var phantomSource = require('phantomjs').path;
+
+ if (path.extname(phantomSource).toLowerCase() === '.cmd') {
+ return path.join(path.dirname( phantomSource ), '//node_modules//phantomjs//lib//phantom//phantomjs.exe');
+ }
+
+ return phantomSource;
+};
/**
* This module's defaults
*/
var defaults = {
input: "robots",
- phantomjs: path.join(__dirname, phantomJS),
+ phantomjs: defaultPhantomJSExePath(),
snapshotScript: path.join(__dirname, snapshotScript),
outputDirClean: false,
pollInterval: 500,
@@ -43,7 +61,7 @@ function worker(input, options, notifier, qcb) {
customModule,
snapshotScript = options.snapshotScript,
phantomjsOptions = Array.isArray(input.phantomjsOptions) ? input.phantomjsOptions : [input.phantomjsOptions];
-
+
// map snapshotScript object script to a real path
if (_.isObject(options.snapshotScript)) {
snapshotScript = path.join(__dirname, phantomDir, options.snapshotScript.script) + ".js";
@@ -77,7 +95,7 @@ function worker(input, options, notifier, qcb) {
});
// start counting
- notifier.add(input.outputFile, input.timeout);
+ notifier.add(input.outputFile, input.timeout);
}
module.exports = {
@@ -110,7 +128,7 @@ module.exports = {
task(_.once(callback));
}, options.processLimit);
- // have the queue call notifier.empty when last item
+ // have the queue call notifier.empty when last item
// from the queue is given to a worker.
q.empty = notifier.qEmpty;
@@ -118,7 +136,7 @@ module.exports = {
options._abort = function(err) {
notifier.abort(q, err);
};
-
+
// generate input for the snapshots
result = inputGenerator.run(options, function(input) {
// give the worker the input and place into the queue
@@ -128,4 +146,4 @@ module.exports = {
return result;
}
-};
\ No newline at end of file
+};
diff --git a/package.json b/package.json
index 10a82142..337d96c4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "html-snapshots",
- "version": "0.9.0",
+ "version": "0.10.0",
"author": {
"name": "Alex Grant",
"email": "alex@localnerve.com",
@@ -21,7 +21,8 @@
"lint": "grunt lint",
"test": "grunt test",
"coverage": "istanbul cover -- grunt test",
- "ci": "grunt lint && istanbul cover -- grunt test && grunt coveralls"
+ "ci": "grunt lint && istanbul cover -- grunt test && grunt coveralls",
+ "validate": "npm ls"
},
"pre-commit": [
"lint"
@@ -58,16 +59,11 @@
"istanbul": "^0.3.14",
"matchdep": "^0.3.0",
"mkdirp": "^0.5.1",
- "precommit-hook": "^2.0.1",
+ "precommit-hook": "^3.0.0",
"sitemap-xml": "~0.1.0"
},
- "licenses": [
- {
- "type": "MIT",
- "url": "https://github.com/localnerve/html-snapshots/blob/master/LICENSE"
- }
- ],
+ "license": "MIT",
"engines": {
- "node": "^0.10.0"
+ "node": "^0.12.0"
}
}