Update checked-in dependencies
This commit is contained in:
parent
4fad06f438
commit
40a500c743
4168 changed files with 298222 additions and 374905 deletions
124
node_modules/open/index.js
generated
vendored
124
node_modules/open/index.js
generated
vendored
|
|
@ -1,11 +1,17 @@
|
|||
const path = require('path');
|
||||
const childProcess = require('child_process');
|
||||
const {promises: fs, constants: fsConstants} = require('fs');
|
||||
const isWsl = require('is-wsl');
|
||||
const isDocker = require('is-docker');
|
||||
const defineLazyProperty = require('define-lazy-prop');
|
||||
import process from 'node:process';
|
||||
import {Buffer} from 'node:buffer';
|
||||
import path from 'node:path';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import childProcess from 'node:child_process';
|
||||
import fs from 'node:fs/promises';
|
||||
import {constants as fsConstants} from 'node:fs'; // TODO: Move this to the above import when targeting Node.js 18.
|
||||
import isWsl from 'is-wsl';
|
||||
import defineLazyProperty from 'define-lazy-prop';
|
||||
import defaultBrowser from 'default-browser';
|
||||
import isInsideContainer from 'is-inside-container';
|
||||
|
||||
// Path to included `xdg-open`.
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const localXdgOpenPath = path.join(__dirname, 'xdg-open');
|
||||
|
||||
const {platform, arch} = process;
|
||||
|
|
@ -75,17 +81,17 @@ const baseOpen = async options => {
|
|||
background: false,
|
||||
newInstance: false,
|
||||
allowNonzeroExitCode: false,
|
||||
...options
|
||||
...options,
|
||||
};
|
||||
|
||||
if (Array.isArray(options.app)) {
|
||||
return pTryEach(options.app, singleApp => baseOpen({
|
||||
...options,
|
||||
app: singleApp
|
||||
app: singleApp,
|
||||
}));
|
||||
}
|
||||
|
||||
let {name: app, arguments: appArguments = []} = options.app || {};
|
||||
let {name: app, arguments: appArguments = []} = options.app ?? {};
|
||||
appArguments = [...appArguments];
|
||||
|
||||
if (Array.isArray(app)) {
|
||||
|
|
@ -93,11 +99,50 @@ const baseOpen = async options => {
|
|||
...options,
|
||||
app: {
|
||||
name: appName,
|
||||
arguments: appArguments
|
||||
}
|
||||
arguments: appArguments,
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
if (app === 'browser' || app === 'browserPrivate') {
|
||||
// IDs from default-browser for macOS and windows are the same
|
||||
const ids = {
|
||||
'com.google.chrome': 'chrome',
|
||||
'google-chrome.desktop': 'chrome',
|
||||
'org.mozilla.firefox': 'firefox',
|
||||
'firefox.desktop': 'firefox',
|
||||
'com.microsoft.msedge': 'edge',
|
||||
'com.microsoft.edge': 'edge',
|
||||
'microsoft-edge.desktop': 'edge',
|
||||
};
|
||||
|
||||
// Incognito flags for each browser in `apps`.
|
||||
const flags = {
|
||||
chrome: '--incognito',
|
||||
firefox: '--private-window',
|
||||
edge: '--inPrivate',
|
||||
};
|
||||
|
||||
const browser = await defaultBrowser();
|
||||
if (browser.id in ids) {
|
||||
const browserName = ids[browser.id];
|
||||
|
||||
if (app === 'browserPrivate') {
|
||||
appArguments.push(flags[browserName]);
|
||||
}
|
||||
|
||||
return baseOpen({
|
||||
...options,
|
||||
app: {
|
||||
name: apps[browserName],
|
||||
arguments: appArguments,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
throw new Error(`${browser.name} is not supported as a default browser`);
|
||||
}
|
||||
|
||||
let command;
|
||||
const cliArguments = [];
|
||||
const childProcessOptions = {};
|
||||
|
|
@ -120,19 +165,19 @@ const baseOpen = async options => {
|
|||
if (app) {
|
||||
cliArguments.push('-a', app);
|
||||
}
|
||||
} else if (platform === 'win32' || (isWsl && !isDocker())) {
|
||||
} else if (platform === 'win32' || (isWsl && !isInsideContainer() && !app)) {
|
||||
const mountPoint = await getWslDrivesMountPoint();
|
||||
|
||||
command = isWsl ?
|
||||
`${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe` :
|
||||
`${process.env.SYSTEMROOT}\\System32\\WindowsPowerShell\\v1.0\\powershell`;
|
||||
command = isWsl
|
||||
? `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`
|
||||
: `${process.env.SYSTEMROOT}\\System32\\WindowsPowerShell\\v1.0\\powershell`;
|
||||
|
||||
cliArguments.push(
|
||||
'-NoProfile',
|
||||
'-NonInteractive',
|
||||
'–ExecutionPolicy',
|
||||
'-ExecutionPolicy',
|
||||
'Bypass',
|
||||
'-EncodedCommand'
|
||||
'-EncodedCommand',
|
||||
);
|
||||
|
||||
if (!isWsl) {
|
||||
|
|
@ -148,9 +193,9 @@ const baseOpen = async options => {
|
|||
if (app) {
|
||||
// Double quote with double quotes to ensure the inner quotes are passed through.
|
||||
// Inner quotes are delimited for PowerShell interpretation with backticks.
|
||||
encodedArguments.push(`"\`"${app}\`""`, '-ArgumentList');
|
||||
encodedArguments.push(`"\`"${app}\`""`);
|
||||
if (options.target) {
|
||||
appArguments.unshift(options.target);
|
||||
appArguments.push(options.target);
|
||||
}
|
||||
} else if (options.target) {
|
||||
encodedArguments.push(`"${options.target}"`);
|
||||
|
|
@ -158,7 +203,7 @@ const baseOpen = async options => {
|
|||
|
||||
if (appArguments.length > 0) {
|
||||
appArguments = appArguments.map(arg => `"\`"${arg}\`""`);
|
||||
encodedArguments.push(appArguments.join(','));
|
||||
encodedArguments.push('-ArgumentList', appArguments.join(','));
|
||||
}
|
||||
|
||||
// Using Base64-encoded command, accepted by PowerShell, to allow special characters.
|
||||
|
|
@ -177,8 +222,8 @@ const baseOpen = async options => {
|
|||
exeLocalXdgOpen = true;
|
||||
} catch {}
|
||||
|
||||
const useSystemXdgOpen = process.versions.electron ||
|
||||
platform === 'android' || isBundled || !exeLocalXdgOpen;
|
||||
const useSystemXdgOpen = process.versions.electron
|
||||
?? (platform === 'android' || isBundled || !exeLocalXdgOpen);
|
||||
command = useSystemXdgOpen ? 'xdg-open' : localXdgOpenPath;
|
||||
}
|
||||
|
||||
|
|
@ -209,7 +254,7 @@ const baseOpen = async options => {
|
|||
subprocess.once('error', reject);
|
||||
|
||||
subprocess.once('close', exitCode => {
|
||||
if (options.allowNonzeroExitCode && exitCode > 0) {
|
||||
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
||||
reject(new Error(`Exited with code ${exitCode}`));
|
||||
return;
|
||||
}
|
||||
|
|
@ -231,16 +276,16 @@ const open = (target, options) => {
|
|||
|
||||
return baseOpen({
|
||||
...options,
|
||||
target
|
||||
target,
|
||||
});
|
||||
};
|
||||
|
||||
const openApp = (name, options) => {
|
||||
export const openApp = (name, options) => {
|
||||
if (typeof name !== 'string') {
|
||||
throw new TypeError('Expected a `name`');
|
||||
}
|
||||
|
||||
const {arguments: appArguments = []} = options || {};
|
||||
const {arguments: appArguments = []} = options ?? {};
|
||||
if (appArguments !== undefined && appArguments !== null && !Array.isArray(appArguments)) {
|
||||
throw new TypeError('Expected `appArguments` as Array type');
|
||||
}
|
||||
|
|
@ -249,8 +294,8 @@ const openApp = (name, options) => {
|
|||
...options,
|
||||
app: {
|
||||
name,
|
||||
arguments: appArguments
|
||||
}
|
||||
arguments: appArguments,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -280,36 +325,37 @@ function detectPlatformBinary({[platform]: platformBinary}, {wsl}) {
|
|||
return detectArchBinary(platformBinary);
|
||||
}
|
||||
|
||||
const apps = {};
|
||||
export const apps = {};
|
||||
|
||||
defineLazyProperty(apps, 'chrome', () => detectPlatformBinary({
|
||||
darwin: 'google chrome',
|
||||
win32: 'chrome',
|
||||
linux: ['google-chrome', 'google-chrome-stable', 'chromium']
|
||||
linux: ['google-chrome', 'google-chrome-stable', 'chromium'],
|
||||
}, {
|
||||
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']
|
||||
}
|
||||
x64: ['/mnt/c/Program Files/Google/Chrome/Application/chrome.exe', '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'],
|
||||
},
|
||||
}));
|
||||
|
||||
defineLazyProperty(apps, 'firefox', () => detectPlatformBinary({
|
||||
darwin: 'firefox',
|
||||
win32: 'C:\\Program Files\\Mozilla Firefox\\firefox.exe',
|
||||
linux: 'firefox'
|
||||
linux: 'firefox',
|
||||
}, {
|
||||
wsl: '/mnt/c/Program Files/Mozilla Firefox/firefox.exe'
|
||||
wsl: '/mnt/c/Program Files/Mozilla Firefox/firefox.exe',
|
||||
}));
|
||||
|
||||
defineLazyProperty(apps, 'edge', () => detectPlatformBinary({
|
||||
darwin: 'microsoft edge',
|
||||
win32: 'msedge',
|
||||
linux: ['microsoft-edge', 'microsoft-edge-dev']
|
||||
linux: ['microsoft-edge', 'microsoft-edge-dev'],
|
||||
}, {
|
||||
wsl: '/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'
|
||||
wsl: '/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe',
|
||||
}));
|
||||
|
||||
open.apps = apps;
|
||||
open.openApp = openApp;
|
||||
defineLazyProperty(apps, 'browser', () => 'browser');
|
||||
|
||||
module.exports = open;
|
||||
defineLazyProperty(apps, 'browserPrivate', () => 'browserPrivate');
|
||||
|
||||
export default open;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue