@controlplane/cli
Version:
Control Plane Corporation CLI
27 lines • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.openInBrowser = openInBrowser;
const open = require("open");
const logger_1 = require("./logger");
// ANCHOR - Exported Functions
/**
* Opens a URL in the user's default browser without ever failing the caller: both a
* rejected launch and an error on the spawned launcher process are logged at debug
* level only. Callers should keep the URL on screen as the fallback.
*
* @param {string} url - The URL to open.
* @returns {Promise<void>} A promise that resolves once the launch attempt settles.
*/
async function openInBrowser(url) {
try {
const opener = await open(url);
// Spawn failures (e.g. a missing launcher) surface on the child process, not the promise
opener.on('error', (e) => {
logger_1.logger.debug(`Failed to open the browser for ${url}`, e);
});
}
catch (e) {
logger_1.logger.debug(`Failed to open the browser for ${url}`, e);
}
}
//# sourceMappingURL=browser.js.map