Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
48 changes: 48 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import prettier from 'eslint-plugin-prettier';
import unicorn from 'eslint-plugin-unicorn';
import globals from 'globals';
import js from '@eslint/js';

export default [
{
ignores: ['vendor/*', 'node_modules/*']
},
js.configs.recommended,
unicorn.configs.recommended,
{
plugins: {
prettier
},

languageOptions: {
globals: {
...globals.node
},

ecmaVersion: 'latest',
sourceType: 'module'
},

rules: {
'prettier/prettier': [
'error',
{
singleQuote: true,
trailingComma: 'none',
arrowParens: 'avoid',
embeddedLanguageFormatting: 'off'
}
],

'require-atomic-updates': 0,
'no-extra-semi': 0,
'no-mixed-spaces-and-tabs': 0,
'unicorn/filename-case': 0,
'unicorn/prevent-abbreviations': 0,
'unicorn/no-array-reduce': 0,
'unicorn/no-array-sort': 0,
'unicorn/no-array-reverse': 0,
'unicorn/prefer-spread': 0
}
}
];
30 changes: 17 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
'use strict';
import os from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { createRequire } from 'node:module';

const os = require('os');
const path = require('path');
const pkg = require('./package');
const require = createRequire(import.meta.url);
const pkg = require('./package.json');
const __dirname = path.dirname(fileURLToPath(import.meta.url));

module.exports = {
version: pkg.version,
binPath: function() {
let driverPath = path.resolve(__dirname, 'vendor', 'msedgedriver');
if (os.platform() === 'win32') {
driverPath = driverPath + '.exe';
}
return driverPath;
export const version = pkg.version;

export function binPath() {
let driverPath = path.resolve(__dirname, 'vendor', 'msedgedriver');
if (os.platform() === 'win32') {
driverPath = driverPath + '.exe';
}
};
return driverPath;
}

export default { version, binPath };
41 changes: 24 additions & 17 deletions install.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
'use strict';
import os from 'node:os';
import path from 'node:path';
import { mkdir, unlink, chmod } from 'node:fs/promises';
import { createWriteStream } from 'node:fs';
import { pipeline } from 'node:stream/promises';
import { Readable } from 'node:stream';
import { fileURLToPath } from 'node:url';
import { createRequire } from 'node:module';
import StreamZip from 'node-stream-zip';

const os = require('node:os');
const path = require('node:path');
const { mkdir, unlink, chmod } = require('node:fs/promises');
const { createWriteStream } = require('node:fs');
const { pipeline } = require('node:stream/promises');
const { Readable } = require('node:stream');
const StreamZip = require('node-stream-zip');
const require = createRequire(import.meta.url);
const pkg = require('./package.json');
const __dirname = path.dirname(fileURLToPath(import.meta.url));

// The version of the driver that will be installed
const EDGEDRIVER_VERSION =
Expand All @@ -25,7 +28,9 @@ function getDriverArchiveName() {
const platform = os.platform();
const arch = os.arch();
if (platform === 'darwin') {
return arch === 'arm64' ? 'edgedriver_mac64_m1.zip' : 'edgedriver_mac64.zip';
return arch === 'arm64'
? 'edgedriver_mac64_m1.zip'
: 'edgedriver_mac64.zip';
}
if (platform === 'linux') {
return 'edgedriver_linux64.zip';
Expand All @@ -34,7 +39,7 @@ function getDriverArchiveName() {
if (arch === 'x64') return 'edgedriver_win64.zip';
if (arch === 'ia32') return 'edgedriver_win32.zip';
}
return undefined;
return;
}

function getDriverUrl(archive) {
Expand Down Expand Up @@ -70,7 +75,7 @@ async function downloadFile(url, destination) {
async function extractArchive(zipPath, destDir) {
const zip = new StreamZip.async({ file: zipPath });
try {
await zip.extract(null, destDir);
await zip.extract(undefined, destDir);
} finally {
await zip.close();
}
Expand All @@ -79,8 +84,8 @@ async function extractArchive(zipPath, destDir) {
async function tryUnlink(p) {
try {
await unlink(p);
} catch (err) {
if (err.code !== 'ENOENT') throw err;
} catch (error) {
if (error.code !== 'ENOENT') throw error;
}
}

Expand Down Expand Up @@ -120,9 +125,11 @@ async function install() {
console.log(`Edgedriver ${EDGEDRIVER_VERSION} installed in ${vendorDir}`);
}

install().catch(err => {
try {
await install();
} catch (error) {
console.error(
`Edgedriver ${EDGEDRIVER_VERSION} could not be installed: ${err.message}`
`Edgedriver ${EDGEDRIVER_VERSION} could not be installed: ${error.message}`
);
process.exit(1);
});
process.exitCode = 1;
}
Loading
Loading