200 lines
9.2 KiB
JavaScript
200 lines
9.2 KiB
JavaScript
var __bare_os_bundle_exports__ = (() => {
|
|
var __create = Object.create;
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __getProtoOf = Object.getPrototypeOf;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
}) : x)(function(x) {
|
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
});
|
|
var __commonJS = (cb, mod) => function __require2() {
|
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
};
|
|
var __export = (target, all) => {
|
|
for (var name in all)
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
};
|
|
var __copyProps = (to, from, except, desc) => {
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
for (let key of __getOwnPropNames(from))
|
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
}
|
|
return to;
|
|
};
|
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
// file that has been converted to a CommonJS file using a Babel-
|
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
mod
|
|
));
|
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
|
|
// ../../node_modules/which-runtime/index.js
|
|
var require_which_runtime = __commonJS({
|
|
"../../node_modules/which-runtime/index.js"(exports) {
|
|
var { runtime, platform, arch } = typeof Bare !== "undefined" ? { runtime: "bare", platform: global.Bare.platform, arch: global.Bare.arch } : typeof process !== "undefined" ? { runtime: "node", platform: global.process.platform, arch: global.process.arch } : typeof Window !== "undefined" ? { runtime: "browser", platform: "unknown", arch: "unknown" } : { runtime: "unknown", platform: "unknown", arch: "unknown" };
|
|
exports.runtime = runtime;
|
|
exports.platform = platform;
|
|
exports.arch = arch;
|
|
exports.isBare = runtime === "bare";
|
|
exports.isBareKit = exports.isBare && typeof BareKit !== "undefined";
|
|
exports.isPear = typeof Pear !== "undefined";
|
|
exports.isNode = runtime === "node";
|
|
exports.isBrowser = runtime === "browser";
|
|
exports.isWindows = platform === "win32";
|
|
exports.isLinux = platform === "linux";
|
|
exports.isMac = platform === "darwin";
|
|
exports.isIOS = platform === "ios" || platform === "ios-simulator";
|
|
exports.isAndroid = platform === "android";
|
|
exports.isElectron = typeof process !== "undefined" && !!global.process.versions?.electron;
|
|
exports.isElectronRenderer = exports.isElectron && global.process.type === "renderer";
|
|
exports.isElectronWorker = exports.isElectron && global.process.type === "worker";
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-which/lib/executable.js
|
|
var require_executable = __commonJS({
|
|
"../../node_modules/bare-which/lib/executable.js"(exports, module) {
|
|
var fs = __require("fs");
|
|
var process2 = __require("process");
|
|
var { isWindows } = require_which_runtime();
|
|
function isExecutableSync(path, options) {
|
|
try {
|
|
const stat = fs.statSync(path);
|
|
const checker = isWindows ? isWin32Executable : isPosixExecutableSync;
|
|
return stat.isFile() && checker({ path, options });
|
|
} catch (err) {
|
|
if (options.ignoreErrors || ["ENOENT", "EACCES"].includes(err.code)) return false;
|
|
throw err;
|
|
}
|
|
}
|
|
async function isExecutable(path, options) {
|
|
try {
|
|
const stat = await fs.promises.stat(path);
|
|
const checker = isWindows ? isWin32Executable : isPosixExecutable;
|
|
return stat.isFile() && await checker({ path, options });
|
|
} catch (err) {
|
|
if (options.ignoreErrors || ["ENOENT", "EACCES"].includes(err.code)) return false;
|
|
throw err;
|
|
}
|
|
}
|
|
function isWin32Executable({ path, options }) {
|
|
const { pathExt = process2.env.PATHEXT || "" } = options;
|
|
const exts = pathExt.split(";");
|
|
if (exts.includes("")) return true;
|
|
return exts.some((ext) => path.toLowerCase().endsWith(ext.toLowerCase()));
|
|
}
|
|
async function isPosixExecutable({ path }) {
|
|
await fs.promises.access(path, fs.constants.X_OK);
|
|
return true;
|
|
}
|
|
function isPosixExecutableSync({ path }) {
|
|
fs.accessSync(path, fs.constants.X_OK);
|
|
return true;
|
|
}
|
|
isExecutable.sync = isExecutableSync;
|
|
module.exports = isExecutable;
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/bare-which/index.js
|
|
var require_bare_which = __commonJS({
|
|
"../../node_modules/bare-which/index.js"(exports, module) {
|
|
var { join, delimiter } = __require("path");
|
|
var process2 = __require("process");
|
|
var { isWindows } = require_which_runtime();
|
|
var isExecutable = require_executable();
|
|
var pathMatcher = isWindows ? /[/\\]/ : /\//;
|
|
var relativePathMatcher = new RegExp(`^\\.${pathMatcher.source}`);
|
|
var isPath = (path) => pathMatcher.test(path);
|
|
var isRelative = (path) => relativePathMatcher.test(path);
|
|
var ErrorNotFound = class extends Error {
|
|
constructor(command) {
|
|
super(`Command not found: ${command}`);
|
|
this.code = "ENOENT";
|
|
}
|
|
};
|
|
function getPathInfo(cmd, {
|
|
path: optPath = process2.env.PATH,
|
|
pathExt: optPathExt = process2.env.PATHEXT,
|
|
delimiter: optDelimiter = delimiter
|
|
}) {
|
|
const pathEnv = !isPath(cmd) ? [...isWindows ? [process2.cwd()] : [], ...(optPath || "").split(optDelimiter)] : [""];
|
|
if (!isWindows) return { pathEnv, pathExt: [""] };
|
|
const pathExtExe = optPathExt || [".EXE", ".CMD", ".BAT", ".COM"].join(optDelimiter);
|
|
const pathExt = pathExtExe.split(optDelimiter).flatMap((item) => [item, item.toLowerCase()]);
|
|
if (cmd.includes(".") && pathExt[0] !== "") pathExt.unshift("");
|
|
return { pathEnv, pathExt, pathExtExe };
|
|
}
|
|
function joinPathCommand(path, cmd) {
|
|
const pathPart = /^".*"$/.test(path) ? path.slice(1, -1) : path;
|
|
const prefix = !pathPart && isRelative(cmd) ? cmd.slice(0, 2) : "";
|
|
return prefix + join(pathPart, cmd);
|
|
}
|
|
function whichSync(cmd, options = {}) {
|
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, options);
|
|
const { all, nothrow } = options;
|
|
const found = [];
|
|
for (const pathEnvPart of pathEnv) {
|
|
const pathCommand = joinPathCommand(pathEnvPart, cmd);
|
|
for (const ext of pathExt) {
|
|
const withExt = pathCommand + ext;
|
|
if (isExecutable.sync(
|
|
withExt,
|
|
{ pathExt: pathExtExe, ignoreErrors: true }
|
|
)) {
|
|
if (!all) return withExt;
|
|
found.push(withExt);
|
|
}
|
|
}
|
|
}
|
|
if (all && found.length) return found;
|
|
if (nothrow) return null;
|
|
throw new ErrorNotFound(cmd);
|
|
}
|
|
async function whichAsync(cmd, options = {}) {
|
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, options);
|
|
const { all, nothrow } = options;
|
|
const foundPromises = [];
|
|
for (const pathEnvPart of pathEnv) {
|
|
const pathCommand = joinPathCommand(pathEnvPart, cmd);
|
|
for (const ext of pathExt) {
|
|
const withExt = pathCommand + ext;
|
|
if (all) {
|
|
foundPromises.push(
|
|
isExecutable(withExt, { pathExt: pathExtExe, ignoreErrors: true }).then((isExec) => isExec ? withExt : null)
|
|
);
|
|
} else if (await isExecutable(
|
|
withExt,
|
|
{ pathExt: pathExtExe, ignoreErrors: true }
|
|
)) return withExt;
|
|
}
|
|
}
|
|
const found = (await Promise.all(foundPromises)).filter((item) => item !== null);
|
|
if (all && found.length > 0) return found;
|
|
if (nothrow) return null;
|
|
throw new ErrorNotFound(cmd);
|
|
}
|
|
whichAsync.sync = whichSync;
|
|
module.exports = whichAsync;
|
|
}
|
|
});
|
|
|
|
// ../../bare-lib-entry-bareWhich.js
|
|
var bare_lib_entry_bareWhich_exports = {};
|
|
__export(bare_lib_entry_bareWhich_exports, {
|
|
default: () => bare_lib_entry_bareWhich_default
|
|
});
|
|
var import_bare_which = __toESM(require_bare_which());
|
|
var bare_lib_entry_bareWhich_default = import_bare_which.default;
|
|
return __toCommonJS(bare_lib_entry_bareWhich_exports);
|
|
})();
|
|
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareWhich"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|