-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
108 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bin/headlessIE.exe binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
bin | ||
npm-debug.log | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
!bin/headlessIE.exe | ||
.gitattributes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,42 @@ | ||
var path = require('path') | ||
var fs = require('fs') | ||
var child_process = require('child_process') | ||
var asap = require('asap') | ||
var asyncify = require('dezalgo') | ||
|
||
var fullPath = path.join(__dirname, '/bin/headlessIE.exe') | ||
|
||
function asapify( cb ) { | ||
var th = this | ||
return function () { | ||
asap( cb.apply( th, arguments ) ) | ||
} | ||
} | ||
var versionsRE = /HeadlessIE ((?:\d+)(?:\.(?:\d+)){0,3}) \(Internet Explorer ((?:\d+)(?:\.(?:\d+)){0,3})\)/g | ||
var fullPath = path.join( __dirname, '/bin/headlessIE.exe' ) | ||
|
||
exports.command = function command(callback) { | ||
asapify(callback) | ||
|
||
callback( undefined, fullPath ) | ||
var cb = asyncify(callback) | ||
|
||
fs.exists( fullPath, function exeExistCommand( present ) { | ||
if( present ) { | ||
cb( undefined, fullPath ) | ||
} else { | ||
cb( 'missing headlessIE executable from package', undefined ) | ||
} | ||
}) | ||
} | ||
|
||
exports.version = function version(callback) { | ||
asapify(callback) | ||
var cb = asyncify(callback) | ||
|
||
try { | ||
var vers = '' | ||
var proc = child_process.spawn( fullPath, [ '--version' ] ) | ||
|
||
proc.stdout.on( 'data', function (data) { | ||
vers += data | ||
}) | ||
|
||
proc.on('close', function (code) { | ||
if( ( code == 0 ) && ( /^(\d+)(\.(\d+)){0,3}/.test( vers ) ) ) { | ||
callback( undefined, vers ) | ||
fs.exists( fullPath, function exeExistVersion( present ) { | ||
if( present ) { | ||
var proc = child_process.execFile( fullPath, [ '--version' ], function VersionRunner( err, stdout ) { | ||
matches = versionsRE.exec( stdout ) | ||
if( matches ) { | ||
cb( undefined, matches[2] ) | ||
} else { | ||
cb( 'Wrong program return to --version argument', undefined ) | ||
} | ||
}) | ||
} else { | ||
callback( "Wrong program return to --version argument", undefined ) | ||
cb( 'missing headlessIE executable from package', undefined ) | ||
} | ||
}) | ||
} catch( e ) { | ||
callback( "Unable to launch program", undefined ) | ||
cb( 'Unable to launch program', undefined ) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters