slnodejs 6.1.630 → 6.1.632

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sl-browser-agent",
3
- "version": "6.1.630",
3
+ "version": "6.1.632",
4
4
  "description": "le Browser Agent!",
5
5
  "main": "dist/browser-agent-all.js",
6
6
  "browser": {
package/lib/preload.js ADDED
@@ -0,0 +1,58 @@
1
+ const { Module } = require('node:module');
2
+ const { resolve } = require('node:path');
3
+
4
+ function main() {
5
+ if (process.env.PRELOAD_EXECUTED) {
6
+ console.log('Skipping preload logic on subsequent entry');
7
+ return;
8
+ }
9
+
10
+ process.env.PRELOAD_EXECUTED = 1;
11
+
12
+ if (require.main === module) {
13
+ console.log('preload.js is the main module, exiting.');
14
+ process.exit(0);
15
+ }
16
+
17
+ /**
18
+ * Get path to node executable dynamically
19
+ */
20
+ const pathToSlAgentCli = resolve(__dirname, './cli.js');
21
+
22
+ let token = '--tokenFile ./sltoken.txt'
23
+ if (process.env.SL_token) {
24
+ token = `--token ${process.env.SL_token}`;
25
+ } else if (process.env.SL_tokenfile) {
26
+ token = `--tokenFile ${process.env.SL_tokenFile}`;
27
+ }
28
+
29
+ let bsid = '--buildSessionIdFile ./buildSessionId'
30
+ if (process.env.SL_buildSessionId) {
31
+ bsid = `--buildSessionId ${process.env.SL_buildSessionId}`;
32
+ } else if (process.env.SL_buildSessionIdFile) {
33
+ bsid = `--buildSessionIdFile ${process.env.SL_buildSessionIdFile}`;
34
+ }
35
+
36
+ /**
37
+ * We shouldn't use cli arguments it is just example
38
+ * env or file config should be used
39
+ */
40
+ const [argv0, ...restArgv] = process.argv;
41
+ const args = `${pathToSlAgentCli} run ${token} ${bsid} --`.split(' ');
42
+ process.argv = [argv0, ...args, ...restArgv];
43
+
44
+ try {
45
+ console.info('Rerun main module with args - ', process.argv.join(' '));
46
+ Module.runMain();
47
+ } catch (error) {
48
+ console.error('Error occurred while executing the target script:', error);
49
+ process.exit(1);
50
+ }
51
+ };
52
+
53
+ main();
54
+
55
+ process.on('uncaughtException', (error) => {
56
+ console.error('Uncaught Exception:', error);
57
+ process.exit(1);
58
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slnodejs",
3
- "version": "6.1.630",
3
+ "version": "6.1.632",
4
4
  "description": "",
5
5
  "main": "tsOutputs/api.js",
6
6
  "scripts": {
@@ -123,6 +123,7 @@
123
123
  },
124
124
  "files": [
125
125
  "lib/cli.js",
126
+ "lib/preload.js",
126
127
  "tsOutputs/cli-parse/*",
127
128
  "tsOutputs/api.d.ts",
128
129
  "tsOutputs/api.js",