chrome-location2
Version:
Approximates the current location of the Chrome browser across platforms.
100 lines (99 loc) • 3.54 kB
JavaScript
;
var __webpack_require__ = {};
(()=>{
__webpack_require__.n = (module)=>{
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
__webpack_require__.d(getter, {
a: getter
});
return getter;
};
})();
(()=>{
__webpack_require__.d = (exports1, definition)=>{
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
enumerable: true,
get: definition[key]
});
};
})();
(()=>{
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
__webpack_require__.r = (exports1)=>{
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
value: 'Module'
});
Object.defineProperty(exports1, '__esModule', {
value: true
});
};
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
default: ()=>locateChrome
});
const external_node_fs_namespaceObject = require("node:fs");
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
const external_userhome_namespaceObject = require("userhome");
var external_userhome_default = /*#__PURE__*/ __webpack_require__.n(external_userhome_namespaceObject);
function scanOsxPath() {
const defaultPath = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
const alternativePath = external_userhome_default()(defaultPath.slice(1));
if (external_node_fs_default().existsSync(defaultPath)) return defaultPath;
return alternativePath;
}
const external_node_path_namespaceObject = require("node:path");
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
function scanWindowsPath() {
let browserPath = null;
const prefixes = [
process.env.LOCALAPPDATA,
process.env.PROGRAMFILES,
process.env['PROGRAMFILES(X86)']
];
const suffix = '\\Google\\Chrome\\Application\\chrome.exe';
for (const prefix of prefixes){
if (!prefix) continue;
const exe = external_node_path_default().join(prefix, suffix);
if (external_node_fs_default().existsSync(exe)) {
browserPath = exe;
break;
}
}
return browserPath;
}
const external_which_namespaceObject = require("which");
var external_which_default = /*#__PURE__*/ __webpack_require__.n(external_which_namespaceObject);
function scanUnknownPlatform() {
let browserPath = null;
try {
browserPath = external_which_default().sync('google-chrome');
} catch (err) {
try {
browserPath = external_which_default().sync('chromium-browser');
} catch (err) {
browserPath = null;
}
}
return browserPath;
}
function locateChrome() {
switch(process.platform){
case 'darwin':
return scanOsxPath();
case 'win32':
return scanWindowsPath();
default:
return scanUnknownPlatform();
}
}
exports["default"] = __webpack_exports__["default"];
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
"default"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
value: true
});