@optima-chat/browser-cli 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -155,10 +155,11 @@ async function requestBinary(path) {
|
|
|
155
155
|
return Buffer.from(arrayBuffer);
|
|
156
156
|
}
|
|
157
157
|
var BrowserAPI = class {
|
|
158
|
-
async createSession(url, profileId) {
|
|
158
|
+
async createSession(url, profileId, force) {
|
|
159
159
|
const body = {};
|
|
160
160
|
if (url) body.url = url;
|
|
161
161
|
if (profileId) body.profile_id = profileId;
|
|
162
|
+
if (force) body.force = true;
|
|
162
163
|
return request("/api/sessions", {
|
|
163
164
|
method: "POST",
|
|
164
165
|
body: JSON.stringify(body)
|
|
@@ -524,16 +525,7 @@ function formatProfileDelete(profileId) {
|
|
|
524
525
|
function registerLifecycleCommands(program2) {
|
|
525
526
|
program2.command("launch").description("Launch a browser session").option("--url <url>", "Navigate to URL after launch").option("--profile <id>", "Use a named browser profile").option("--force", "Close existing session before launching").action(async (opts) => {
|
|
526
527
|
try {
|
|
527
|
-
|
|
528
|
-
try {
|
|
529
|
-
const existingId = loadSessionId();
|
|
530
|
-
await api.closeSession(existingId);
|
|
531
|
-
clearSessionId();
|
|
532
|
-
} catch {
|
|
533
|
-
clearSessionId();
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
const state = await api.createSession(opts.url, opts.profile);
|
|
528
|
+
const state = await api.createSession(opts.url, opts.profile, opts.force);
|
|
537
529
|
saveSessionId(state.session_id);
|
|
538
530
|
console.log(formatLaunch(state));
|
|
539
531
|
} catch (err) {
|