grunt-lib-phantomjs
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -20,2 +20,3 @@ /* | ||
var EventEmitter2 = require('eventemitter2').EventEmitter2; | ||
var rimraf = require('rimraf'); | ||
@@ -51,4 +52,4 @@ // Get path to phantomjs binary | ||
// Default options. | ||
if (typeof options.killTimeout !== 'number') { options.timeout = 5000; } | ||
options.options = options.options || {}; | ||
if (typeof options.killTimeout !== 'number') { options.killTimeout = 1000; } | ||
options.options = options.options || {}; | ||
@@ -58,8 +59,10 @@ // All done? Clean up! | ||
clearTimeout(id); | ||
tempfile.unlink(); | ||
var kill = function(){ | ||
var kill = function() { | ||
// Only kill process if it has a pid, otherwise an error would be thrown. | ||
if (phantomJSHandle.pid){ | ||
if (phantomJSHandle.pid) { | ||
phantomJSHandle.kill(); | ||
} | ||
rimraf(tempfile.path, function(err) { | ||
if (err) { throw err; } | ||
}); | ||
if (typeof done === 'function') { done(null); } | ||
@@ -174,3 +177,3 @@ }; | ||
// Ignore intentional cleanup. | ||
if (code === 15 || code === null /* SIGTERM */){ return; } | ||
if (code === 15 || code === null /* SIGTERM */) { return; } | ||
@@ -177,0 +180,0 @@ // If we're here, something went horribly wrong. |
{ | ||
"name": "grunt-lib-phantomjs", | ||
"description": "Grunt and PhantomJS, sitting in a tree", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"author": { | ||
@@ -20,11 +20,11 @@ "name": "Grunt Team", | ||
"phantomjs-prebuilt": "^2.1.3", | ||
"semver": "^4.3.0", | ||
"rimraf": "^2.5.2", | ||
"semver": "^5.1.0", | ||
"temporary": "^0.0.8" | ||
}, | ||
"devDependencies": { | ||
"difflet": "^0.2.3", | ||
"difflet": "^1.0.1", | ||
"express": "^4.11.2", | ||
"grunt": "^0.4.5", | ||
"grunt-cli": "^0.1.13", | ||
"grunt-contrib-jshint": "^0.11.0" | ||
"grunt": "^1.0.1", | ||
"grunt-contrib-jshint": "^1.0.0" | ||
}, | ||
@@ -35,3 +35,4 @@ "main": "lib/phantomjs", | ||
"phantomjs" | ||
] | ||
], | ||
"appveyor_id": "69g3o5c5m0fyih9r" | ||
} |
@@ -9,3 +9,3 @@ /* | ||
/*global phantom:true*/ | ||
/* jshint phantom:true */ | ||
@@ -84,3 +84,3 @@ 'use strict'; | ||
sendMessage(JSON.parse(str)); | ||
} catch(err) { | ||
} catch (err) { | ||
sendMessage('error.invalidJSON', str); | ||
@@ -123,3 +123,3 @@ } | ||
page.evaluate(function() { | ||
/*jshint browser:true, devel:true */ | ||
/* jshint browser:true, devel:true */ | ||
document.addEventListener('DOMContentLoaded', function() { | ||
@@ -126,0 +126,0 @@ alert('inject'); |
@@ -1,2 +0,2 @@ | ||
# grunt-lib-phantomjs [![Build Status](https://travis-ci.org/gruntjs/grunt-lib-phantomjs.png?branch=master)](https://travis-ci.org/gruntjs/grunt-lib-phantomjs) | ||
# grunt-lib-phantomjs [![Build Status: Linux](https://travis-ci.org/gruntjs/grunt-lib-phantomjs.svg?branch=master)](https://travis-ci.org/gruntjs/grunt-lib-phantomjs) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/69g3o5c5m0fyih9r/branch/master?svg=true)](https://ci.appveyor.com/project/gruntjs/grunt-lib-phantomjs/branch/master) | ||
@@ -12,9 +12,3 @@ > Grunt and PhantomJS, sitting in a tree. | ||
### Options | ||
* `timeout`: PhantomJS' timeout, in milliseconds. | ||
* `inject`: JavaScript to inject into the page. | ||
* `page`: an object of options for the PhantomJS [`page` object](https://github.com/ariya/phantomjs/wiki/API-Reference-WebPage). | ||
* `screenshot`: saves a screenshot on failure | ||
## An inline example | ||
@@ -109,2 +103,83 @@ | ||
## API | ||
### phantomjs.halt() | ||
Call this when everything has finished successfully, or when something horrible happens, and you need to clean up and abort. | ||
### phantomjs.spawn(pageURL, options) | ||
Spawn a `PhantomJS` process. The method returns a reference to the spawned process. | ||
This method has the following arguments: | ||
#### pageURL | ||
Type: `string` | ||
Default: no default value, the user has to set it explicitly. | ||
URL or path to the page .html test file to run. | ||
#### Options | ||
Type: `object` | ||
The options object has these possible properties: | ||
##### done | ||
Type: `function` | ||
Default: no default value, the user has to set it explicitly. | ||
The callback to call when the task is done. | ||
##### failCode | ||
Type: `number` | ||
Default: 0 | ||
The error code to exit with when an Error occurs. | ||
##### killTimeout | ||
Type: `number` | ||
Default: `1000` ms | ||
The timeout in milliseconds after which the PhantomJS process will be killed. | ||
##### options (PhantomJS options) | ||
Type: `object` | ||
Default: `{}` | ||
Additional options to passe to `PhantomJS`. This object has the following properties: | ||
###### timeout | ||
Type: `number` | ||
Default: `undefined` | ||
PhantomJS' timeout, in milliseconds. | ||
###### inject | ||
Type: `string|array` | ||
Default: `undefined` | ||
One or multiple (array) JavaScript file names to inject into the page. | ||
###### page | ||
Type: `object` | ||
Default: `undefined` | ||
An object of options for the PhantomJS [`page` object](https://github.com/ariya/phantomjs/wiki/API-Reference-WebPage). | ||
###### screenshot | ||
Type: `boolean` | ||
Default: `undefined` | ||
Saves a screenshot on failure | ||
## OS Dependencies | ||
@@ -111,0 +186,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18037
4
299
190
5
1
+ Addedrimraf@^2.5.2
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removedsemver@4.3.6(transitive)
Updatedsemver@^5.1.0