Permalink
Browse files

abstract environment updated for better support of vendors injecting (#…

  • Loading branch information...
jifeon authored and maZahaca committed Oct 7, 2017
1 parent 82293b5 commit aaf5866bc4244878f37926c0b09247460edcc771
Showing with 9 additions and 23 deletions.
  1. +7 −21 lib/PhantomEnvironment.js
  2. +2 −2 package.json
View
@@ -141,7 +141,7 @@ class PhantomEnvironment extends AbstractEnvironment {
.then(this._rotateProxy, this)
.then(this._navigateTo.bind(this, this._url))
.then(this._validateProxy, this)
.then(this._inject, this);
.then(this._injectVendors, this);
}
setProxy(proxy) {
@@ -239,7 +239,7 @@ class PhantomEnvironment extends AbstractEnvironment {
});
debug('Added page load callback');
return deferred.promise().then(this._inject, this);
return deferred.promise().then(this._injectVendors, this);
}
waitForQuery(uri, timeout) {
@@ -670,24 +670,10 @@ class PhantomEnvironment extends AbstractEnvironment {
return Array.isArray(proxy) ? proxy.pop() : null;
}
/**
* Inject libs which are required for parse process
*
* @private
*/
_inject() {
debug('.inject()-ing parser libs');
const files = [
require.resolve('goose-abstract-environment/vendor/sizzle.min.js'),
require.resolve('goose-abstract-environment/vendor/xhr.sniffer.js'),
];
return this._injectFiles(files);
}
_injectFiles(files) {
files.forEach((file) => {
debug('injecting file %s', file);
this._page.injectJs(path.join(__dirname, '..', file));
_injectFiles(filePaths) {
filePaths.forEach((filePath) => {
debug('injecting file %s', filePath);
this._page.injectJs(filePath);
});
return vow.resolve();
}
@@ -699,7 +685,7 @@ class PhantomEnvironment extends AbstractEnvironment {
debug('.inject()-ing browser env libs');
return this._injectFiles([
'build/browser.bundle.js',
path.join(__dirname, '../build/browser.bundle.js'),
]);
}
View
@@ -1,6 +1,6 @@
{
"private": true,
"version": "1.0.5",
"version": "1.0.8",
"name": "goose-phantom-environment",
"main": "lib/PhantomEnvironment.js",
"repository": "redco/goose-phantom-environment",
@@ -9,7 +9,7 @@
"dependencies": {
"babel-polyfill": "^6.23.0",
"debug": "^3.0.1",
"goose-abstract-environment": "1.0.6",
"goose-abstract-environment": "1.0.8",
"lodash": "^4.17.4",
"mkdir-p": "^0.0.7",
"phantom": "^0.8.4",

0 comments on commit aaf5866

Please sign in to comment.