gologin 1.0.30 → 1.0.31

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.
@@ -260,7 +260,8 @@ class BrowserChecker {
260
260
  async replaceBrowser() {
261
261
  console.log('Copy Orbita to target path');
262
262
  if (PLATFORM === 'darwin') {
263
- await rmdir(path.join(this.#browserPath, 'Orbita-Browser.app'), { recursive: true });
263
+ await this.deleteDir(path.join(this.#browserPath, 'Orbita-Browser.app'));
264
+
264
265
  const files = await readdir(path.join(this.#browserPath, EXTRACTED_FOLDER));
265
266
  const promises = [];
266
267
  files.forEach((filename) => {
@@ -268,22 +269,25 @@ class BrowserChecker {
268
269
  promises.push(copyFile(path.join(this.#browserPath, EXTRACTED_FOLDER, filename), path.join(this.#browserPath, filename)));
269
270
  }
270
271
  });
272
+
271
273
  return Promise.all(promises);
272
- } else {
273
- await rmdir(path.join(this.#browserPath, 'orbita-browser'), { recursive: true });
274
- await this.copyDir(
275
- path.join(this.#browserPath, EXTRACTED_FOLDER, 'orbita-browser'),
276
- path.join(this.#browserPath, 'orbita-browser')
277
- );
278
274
  }
275
+
276
+ const targetBrowserPath = path.join(this.#browserPath, 'orbita-browser');
277
+ await this.deleteDir(targetBrowserPath);
278
+
279
+ await this.copyDir(
280
+ path.join(this.#browserPath, EXTRACTED_FOLDER, 'orbita-browser'),
281
+ targetBrowserPath
282
+ );
279
283
  }
280
284
 
281
285
  async deleteOldArchives(deleteCurrentBrowser = false) {
282
286
  if (deleteCurrentBrowser) {
283
- return await rmdir(path.join(this.#browserPath), { recursive: true });
287
+ return this.deleteDir(path.join(this.#browserPath));
284
288
  }
285
289
 
286
- await rmdir(path.join(this.#browserPath, EXTRACTED_FOLDER), { recursive: true });
290
+ await this.deleteDir(path.join(this.#browserPath, EXTRACTED_FOLDER));
287
291
  return readdir(this.#browserPath)
288
292
  .then((files) => {
289
293
  const promises = [];
@@ -355,6 +359,19 @@ class BrowserChecker {
355
359
  get getOrbitaPath() {
356
360
  return this.#executableFilePath;
357
361
  }
362
+
363
+ async deleteDir(path = '') {
364
+ if (!path) {
365
+ return;
366
+ }
367
+
368
+ const directoryExists = await access(path).then(() => true).catch(() => false);
369
+ if (!directoryExists) {
370
+ return;
371
+ }
372
+
373
+ return rmdir(path, { recursive: true });
374
+ }
358
375
  }
359
376
 
360
377
  module.exports = BrowserChecker;
package/gologin.js CHANGED
@@ -359,7 +359,7 @@ class GoLogin {
359
359
  profile.proxy.password = _.get(profile, 'autoProxyPassword');
360
360
  }
361
361
  // console.log('proxy=', proxy);
362
-
362
+
363
363
  if (proxy.mode === 'geolocation') {
364
364
  proxy.mode = 'http';
365
365
  }
@@ -1098,7 +1098,7 @@ class GoLogin {
1098
1098
  if (try_count < 3) {
1099
1099
  return this.waitDebuggingUrl(delay_ms, try_count+1);
1100
1100
  }
1101
- return { 'status': 'failure', wsUrl }
1101
+ return { 'status': 'failure', wsUrl, 'message': 'Check proxy settings', 'profile_id': this.profile_id }
1102
1102
  }
1103
1103
 
1104
1104
  wsUrl = wsUrl.replace('ws://', `wss://`).replace('127.0.0.1', `${this.profile_id}.orbita.gologin.com`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gologin",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "description": "A high-level API to control Orbita browser over GoLogin API",
5
5
  "main": "./gologin.js",
6
6
  "repository": {