Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ShowVer.exe #125

Merged
merged 27 commits into from
Jun 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0572694
Use wmic to get browser version
hellokatili Oct 26, 2020
3439206
Remove ShowVer.exe
hellokatili Oct 26, 2020
52877dd
Merge branch 'master' into remove-showver.exe
bmomberger-bitovi Jun 2, 2022
7bfc2bb
Add a windows target to the ci matrix
bmomberger-bitovi Jun 2, 2022
a4c43eb
Add semicolons to placate linter
bmomberger-bitovi Jun 2, 2022
c6eabdc
Add semicolons to placate linter
bmomberger-bitovi Jun 2, 2022
1cb02a8
Add switches to try to fix firefox install stallling
bmomberger-bitovi Jun 2, 2022
d7e58e3
Does the firefox addon work instead?
bmomberger-bitovi Jun 2, 2022
a585fe4
Merge branch 'master' into remove-showver.exe
bmomberger-bitovi Jun 3, 2022
df37f3e
Add the local bin dir to PATH
bmomberger-bitovi Jun 3, 2022
82a908a
debug the path
bmomberger-bitovi Jun 3, 2022
3c0b0e1
change install step to before_install
bmomberger-bitovi Jun 3, 2022
7ee4d59
Update .travis.yml
bmomberger-bitovi Jun 3, 2022
131ac48
Remove JSON stringify from test file
bmomberger-bitovi Jun 3, 2022
95b71e4
Try commenting out half of the windows platform
bmomberger-bitovi Jun 3, 2022
bfe39cb
placate linter
bmomberger-bitovi Jun 3, 2022
5969709
Revert removal of JSON.stringify
bmomberger-bitovi Jun 3, 2022
a634a7e
Is there an electron.exe?
bmomberger-bitovi Jun 3, 2022
d9e21d2
use cmd.exe to launch phantom and electron
bmomberger-bitovi Jun 3, 2022
f5d3dac
placate linter
bmomberger-bitovi Jun 3, 2022
fcf1d41
Fix launching with execFile (use shell where appropriate)
bmomberger-bitovi Jun 5, 2022
c6cfe4b
Add args back to phantom config in windows
bmomberger-bitovi Jun 5, 2022
5d87c6f
Force kill phantomjs on windows
bmomberger-bitovi Jun 5, 2022
a4a17be
use YARN_GPG env var to make windows build terminate
bmomberger-bitovi Jun 5, 2022
c609452
Look at running processes after success
bmomberger-bitovi Jun 5, 2022
7353a5f
use tasklist instead of ps
bmomberger-bitovi Jun 5, 2022
04a07f2
force kill electron as it is not terminating on windows CI
bmomberger-bitovi Jun 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sudo: true
language: node_js

node_js:
- 10
- 14

matrix:
include:
Expand All @@ -12,6 +12,13 @@ matrix:
chrome: stable
- os: osx
osx_image: xcode10.1



- os: windows
addons:
firefox: latest
before_install:
- choco install googlechrome --acceptlicense --yes --no-progress --ignore-checksums
- export PATH=$PATH:"${TRAVIS_BUILD_DIR}/node_modules/.bin"
env:
- YARN_GPG=no
after_success:
- tasklist
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module.exports = function (grunt) {
simplemocha: {
options: {
timeout: 600000,
reporter: 'spec'
reporter: 'spec',
path: process.env.PWD
},
all: { src: ['test/**/*.js'] }
},
Expand Down
23 changes: 16 additions & 7 deletions lib/local/instance.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var path = require('path');
var spawn = require("child_process").spawn;
var exec = require("child_process").exec;
var execFile = require("child_process").execFile;
var EventEmitter = require('events').EventEmitter;
Expand Down Expand Up @@ -38,11 +37,18 @@ var Instance = function (cmd, args, settings, options) {
this.options = options || {};
var self = this;

var childProcess = args === null ? exec(cmd, settings || {}) : spawn(cmd, args, settings || {});
var childProcess = args === null ?
exec(cmd, settings || {}) :
execFile(cmd, args, settings || { shell: !!options.subshell });

debug( (args === null ? 'exec' : 'spawn') + ' child process with process id',
debug( (args === null ? 'exec' : 'execFile') + ' child process with process id',
childProcess.pid, cmd, args);

childProcess.on('error', function(error) {
debug("error caught", error);
self.emit('exit', { code: error.status, signal: 15 });
});

childProcess.on('exit', function (code, signal) {
self.emit('stop', {
code: code,
Expand Down Expand Up @@ -103,10 +109,13 @@ Instance.prototype.stop = function (callback) {
execFile('osascript', ['-e', command]);
} else if (process.platform === 'win32') {
//Adding `"` wasn't safe/functional on Win systems
command = 'taskkill /IM ' + (this.options.imageName || path.basename(this.cmd));
debug('Executing shutdown taskkil', command);
command = command.split(' ');
execFile(command[0], command.slice(1)).once('exit', function(data) {
debug('Executing shutdown taskkill on', this.options.imageName || path.basename(this.cmd));
execFile(
'taskkill',
(this.options.forceKill ? ['/F'] : []).concat(
['/IM', this.options.imageName || path.basename(this.cmd)]
)
).once('exit', function(data) {
self.emit('stop', data);
});
} else {
Expand Down
11 changes: 9 additions & 2 deletions lib/local/platform/windows.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

var os = require('os');
var fs = require('fs');
var path = require('path');
//Windows 64bits "Program Files"
//Windows 32bits "Program Files x86"
var programFiles = os.arch() === "x64" ? process.env.ProgramFiles : process.env["ProgramFiles(x86)"];
var programFiles = os.arch() === "x64" ? process.env.ProgramFiles : ( process.env["ProgramFiles(x86)"] || process.env.ProgramFiles );
var cwd = path.normalize(programFiles);
var appData = appData || process.env.APPDATA;

Expand Down Expand Up @@ -50,18 +51,24 @@ module.exports = {
electron: {
defaultLocation: path.join(process.cwd(), 'node_modules', '.bin', 'electron.cmd'),
pathQuery: 'dir /s /b electron.exe',
imageName: 'electron.exe',
args: [path.join(__dirname, '..', '..', '..', 'resources', 'electron.js')],
multi: true,
subshell: true,
forceKill: true,
cwd: cwd
},
phantom: {
defaultLocation: [
path.join(process.cwd(), 'node_modules', '.bin', 'phantomjs'),
path.join(programFiles, 'phantomjs', 'phantomjs.exe')
],
pathQuery: 'dir /s /b phantomjs.exe',
imageName: 'phantomjs.exe',
args: [path.join(__dirname, '..', '..', '..', 'resources', 'phantom.js')],
pathQuery: 'dir /s /b phantomjs.exe',
multi: true,
subshell: true,
forceKill: true,
cwd: cwd
},
nodeWebkit: {
Expand Down
63 changes: 49 additions & 14 deletions lib/local/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,26 @@ module.exports = function(browser) {
return Q(null);
}

// Run ShowVer.exe and parse out ProductVersion key (Windows)
// Use WMIC to get browser version
if (process.platform === 'win32') {
var command = path.join('"' + __dirname, '..', '..', 'resources', 'ShowVer.exe" "' + browser.command + '"');
var deferred = Q.defer();
PromiseExec('wmic datafile where "name=\'' + browser.command.replace(/\\/gi, '\\\\') + '\'" get version')
.then(function (exeVersion) {
var versionSplit = exeVersion.stdout.split('\n');
var versionString = versionSplit[1].trim();
var regex = /\s*(.*)/;
if (typeof versionString === 'string' && regex.test(versionString)) {
browser.version = versionString;
debug('Found browser version', browser.name, browser.version);
} else {
debug("Did not find browser version", browser.name);
}

debug('Retrieving version for windows executable', command);
// Can't use Q.nfcall here unfortunately because of non 0 exit code
execFile(command.split(' ')[0], command.split(' ').slice(1), function(error, stdout) {
var regex = /ProductVersion:\s*(.*)/;
// ShowVer.exe returns a non zero status code even if it works
if (typeof stdout === 'string' && regex.test(stdout)) {
browser.version = stdout.match(regex)[1];
debug('Found browser version', browser.name, browser.version);
}

return deferred.resolve(browser);
return deferred.resolve(browser);
}, function(error) {
debug("error when getting browser version for", browser.name);
return deferred.reject(error);
});

return deferred.promise;
}

Expand Down Expand Up @@ -69,3 +71,36 @@ module.exports = function(browser) {
return browser;
});
};

/**
* @param {string} app command to execute
* @returns {Promise<{stdout:string, stderr:string, code:number}>}
*/
function PromiseExec(app) {
var deferred = Q.defer();
var child = execFile(app.split(' ')[0], app.split(' ').slice(1), { shell: true });
var stdout = '';
var stderr = '';

debug("about to exec", app);

child.addListener('error', function(error) {
debug("error caught in PromiseExec", error);
deferred.reject(error);
});

child.stdout.on('data', function (data) {
stdout += data;
});

child.stderr.on('data', function (data) {
stderr += data;
});

child.addListener('exit', function (code) {
debug("PromiseExec: app exited with code", code, ":", app);
deferred.resolve({ stdout: stdout, stderr: stderr, code: code} );
});

return deferred.promise;
}
Loading