webdriver-installer 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/utils.js +20 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
### [1.1.4](https://github.com/joeyparrish/webdriver-installer/compare/v1.1.3...v1.1.4) (2022-02-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* Fix unlinking existing binaries ([#12](https://github.com/joeyparrish/webdriver-installer/issues/12)) ([8a43765](https://github.com/joeyparrish/webdriver-installer/commit/8a43765b54fbbf164762f7a8edf52520b4d08059))
|
|
9
|
+
|
|
3
10
|
### [1.1.3](https://github.com/joeyparrish/webdriver-installer/compare/v1.1.2...v1.1.3) (2022-02-11)
|
|
4
11
|
|
|
5
12
|
|
package/package.json
CHANGED
package/utils.js
CHANGED
|
@@ -84,37 +84,37 @@ class InstallerUtils {
|
|
|
84
84
|
/**
|
|
85
85
|
* Get a version number from the Windows registry.
|
|
86
86
|
*
|
|
87
|
-
* @param {string}
|
|
87
|
+
* @param {string} regPath
|
|
88
88
|
* @param {string} key
|
|
89
89
|
* @return {!Promise<?string>}
|
|
90
90
|
*/
|
|
91
|
-
static async getWindowsRegistryVersion(
|
|
91
|
+
static async getWindowsRegistryVersion(regPath, key) {
|
|
92
92
|
if (os.platform() != 'win32') {
|
|
93
93
|
return null;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
// Try the 64-bit registry first, then fall back to the 32-bit registry.
|
|
97
97
|
// Necessary values could be in either location.
|
|
98
|
-
let result = await regQuery(
|
|
99
|
-
if (!result[
|
|
100
|
-
result = await regQuery(
|
|
98
|
+
let result = await regQuery(regPath, '64');
|
|
99
|
+
if (!result[regPath].exists || !result[regPath].values[key]) {
|
|
100
|
+
result = await regQuery(regPath, '32');
|
|
101
101
|
}
|
|
102
|
-
if (!result[
|
|
102
|
+
if (!result[regPath].exists || !result[regPath].values[key]) {
|
|
103
103
|
return null;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
return result[
|
|
106
|
+
return result[regPath].values[key].value;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* Test if a file exists.
|
|
111
111
|
*
|
|
112
|
-
* @param {
|
|
112
|
+
* @param {filePath}
|
|
113
113
|
* @return {!Promise<boolean}
|
|
114
114
|
*/
|
|
115
|
-
static async fileExists(
|
|
115
|
+
static async fileExists(filePath) {
|
|
116
116
|
try {
|
|
117
|
-
await fsPromises.stat(
|
|
117
|
+
await fsPromises.stat(filePath);
|
|
118
118
|
return true;
|
|
119
119
|
} catch (error) {
|
|
120
120
|
return false;
|
|
@@ -124,22 +124,23 @@ class InstallerUtils {
|
|
|
124
124
|
/**
|
|
125
125
|
* Get a version number from the metadata of a Windows executable.
|
|
126
126
|
*
|
|
127
|
-
* @param {string}
|
|
127
|
+
* @param {string} executablePath
|
|
128
128
|
* @return {!Promise<?string>}
|
|
129
129
|
*/
|
|
130
|
-
static async getWindowsExeVersion(
|
|
130
|
+
static async getWindowsExeVersion(executablePath) {
|
|
131
131
|
if (os.platform() != 'win32') {
|
|
132
132
|
return null;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
if (!(await InstallerUtils.fileExists(
|
|
135
|
+
if (!(await InstallerUtils.fileExists(executablePath))) {
|
|
136
136
|
// No such file.
|
|
137
137
|
// If it's a relative path, ask the registry for a full one.
|
|
138
|
-
if (!
|
|
139
|
-
|
|
140
|
-
WINDOWS_REGISTRY_APP_PATHS +
|
|
138
|
+
if (!executablePath.includes('/') && !executablePath.includes('\\')) {
|
|
139
|
+
executablePath = await InstallerUtils.getWindowsRegistryVersion(
|
|
140
|
+
WINDOWS_REGISTRY_APP_PATHS + executablePath,
|
|
141
141
|
'');
|
|
142
|
-
if (!
|
|
142
|
+
if (!executablePath ||
|
|
143
|
+
!(await InstallerUtils.fileExists(executablePath))) {
|
|
143
144
|
return null;
|
|
144
145
|
}
|
|
145
146
|
}
|
|
@@ -147,7 +148,7 @@ class InstallerUtils {
|
|
|
147
148
|
|
|
148
149
|
const result = await InstallerUtils.runCommand([
|
|
149
150
|
'powershell',
|
|
150
|
-
`(Get-Item "${
|
|
151
|
+
`(Get-Item "${executablePath}").VersionInfo.ProductVersion`,
|
|
151
152
|
]);
|
|
152
153
|
|
|
153
154
|
const output = result.stdout.trim();
|
|
@@ -330,7 +331,7 @@ class InstallerUtils {
|
|
|
330
331
|
// permission errors overwriting it. Unlinking it first will ensure the
|
|
331
332
|
// newly-written file is a fresh filesystem inode that doesn't conflict
|
|
332
333
|
// with what's running.
|
|
333
|
-
if (await InstallerUtils.fileExists(
|
|
334
|
+
if (await InstallerUtils.fileExists(outputPath)) {
|
|
334
335
|
await fsPromises.unlink(outputPath);
|
|
335
336
|
}
|
|
336
337
|
|