[Gradle, Wasm] Detect correct browser executable depends on OS
This commit is contained in:
committed by
Space Team
parent
c4eca5f2df
commit
e93fa380e2
@@ -50,6 +50,7 @@ tasks {
|
||||
"tc-log-appender.js",
|
||||
"tc-log-error-webpack.js",
|
||||
"webpack-5-debug.js",
|
||||
"detect-correct-browser.js",
|
||||
"package.json",
|
||||
"rollup.config.js",
|
||||
"tsconfig.json",
|
||||
@@ -76,6 +77,7 @@ tasks {
|
||||
val jar by tasks.creating(Jar::class) {
|
||||
dependsOn(tasks.named("yarnBuild"))
|
||||
from(projectDir.resolve("lib"))
|
||||
from(projectDir.resolve("package.json"))
|
||||
}
|
||||
|
||||
artifacts {
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const isWsl = require('is-wsl');
|
||||
const {platform, arch} = process;
|
||||
|
||||
function detectArchBinary(binary) {
|
||||
if (typeof binary === 'string' || Array.isArray(binary)) {
|
||||
return binary;
|
||||
}
|
||||
|
||||
const {[arch]: archBinary} = binary;
|
||||
|
||||
if (!archBinary) {
|
||||
throw new Error(`${arch} is not supported`);
|
||||
}
|
||||
|
||||
return archBinary;
|
||||
}
|
||||
|
||||
// Return location of chrome.exe file for a given Chrome directory (available: "Chrome", "Chrome SxS").
|
||||
function getChromeExe(chromeDirName) {
|
||||
// Only run these checks on win32
|
||||
if (process.platform !== 'win32') {
|
||||
return null
|
||||
}
|
||||
let windowsChromeDirectory, i, prefix;
|
||||
const suffix = '\\Google\\' + chromeDirName + '\\Application\\chrome.exe';
|
||||
const prefixes = [process.env.LOCALAPPDATA, process.env.PROGRAMFILES, process.env['PROGRAMFILES(X86)']];
|
||||
|
||||
for (i = 0; i < prefixes.length; i++) {
|
||||
prefix = prefixes[i]
|
||||
try {
|
||||
windowsChromeDirectory = path.join(prefix, suffix)
|
||||
fs.accessSync(windowsChromeDirectory)
|
||||
return windowsChromeDirectory
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
return windowsChromeDirectory
|
||||
}
|
||||
|
||||
function detectPlatformBinary({[platform]: platformBinary}, {wsl}) {
|
||||
if (wsl && isWsl) {
|
||||
return detectArchBinary(wsl);
|
||||
}
|
||||
|
||||
if (!platformBinary) {
|
||||
throw new Error(`${platform} is not supported`);
|
||||
}
|
||||
|
||||
return detectArchBinary(platformBinary);
|
||||
}
|
||||
|
||||
const apps = {};
|
||||
|
||||
function define(browserName, platforms, wsl) {
|
||||
Object.defineProperty(apps, browserName, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
value: {
|
||||
bin: detectPlatformBinary(platforms, wsl)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
define(
|
||||
'chrome',
|
||||
{
|
||||
darwin: 'google chrome',
|
||||
win32: getChromeExe("Chrome"),
|
||||
linux: ['google-chrome', 'google-chrome-stable']
|
||||
},
|
||||
{
|
||||
wsl: {
|
||||
ia32: '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe',
|
||||
x64: ['/mnt/c/Program Files/Google/Chrome/Application/chrome.exe', '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe']
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
define(
|
||||
'chrome canary',
|
||||
{
|
||||
darwin: 'google chrome canary',
|
||||
win32: getChromeExe("Chrome SxS"),
|
||||
linux: ['google-chrome-canary', 'google-chrome-unstable']
|
||||
},
|
||||
{
|
||||
wsl: {
|
||||
ia32: '/mnt/c/Program Files (x86)/Google/Chrome SxS/Application/chrome.exe',
|
||||
x64: ['/mnt/c/Program Files/Google/Chrome SxS/Application/chrome.exe', '/mnt/c/Program Files (x86)/Google/Chrome SxS/Application/chrome.exe']
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = apps
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@kotlin/js-tests-teamcity",
|
||||
"name": "kotlin-test-js-runner",
|
||||
"version": "0.0.1",
|
||||
"description": "Simple Kotlin/JS tests runner with TeamCity reporter",
|
||||
"main": "lib/index.js",
|
||||
@@ -26,6 +26,7 @@
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"typescript": "^3.7.2",
|
||||
"format-util": "^1.0.5",
|
||||
"tslib": "^2.3.1"
|
||||
"tslib": "^2.3.1",
|
||||
"is-wsl": "^2.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,14 @@ export default [
|
||||
file: 'lib/mocha-kotlin-reporter.js',
|
||||
format: 'cjs'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
input: './detect-correct-browser.js',
|
||||
output: {
|
||||
file: 'lib/detect-correct-browser.js',
|
||||
format: 'esm'
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
function plugins() {
|
||||
|
||||
@@ -302,6 +302,11 @@ is-core-module@^2.8.1:
|
||||
dependencies:
|
||||
has "^1.0.3"
|
||||
|
||||
is-docker@^2.0.0:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa"
|
||||
integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==
|
||||
|
||||
is-module@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591"
|
||||
@@ -314,6 +319,13 @@ is-reference@^1.2.1:
|
||||
dependencies:
|
||||
"@types/estree" "*"
|
||||
|
||||
is-wsl@^2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271"
|
||||
integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==
|
||||
dependencies:
|
||||
is-docker "^2.0.0"
|
||||
|
||||
jest-worker@^26.2.1:
|
||||
version "26.6.2"
|
||||
resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.2.tgz#7f72cbc4d643c365e27b9fd775f9d0eaa9c7a8ed"
|
||||
|
||||
Reference in New Issue
Block a user