bare-script 2.2.3 → 2.2.4

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.
Files changed (2) hide show
  1. package/lib/bare.js +10 -3
  2. package/package.json +1 -1
package/lib/bare.js CHANGED
@@ -42,6 +42,7 @@ options:
42
42
  * @ignore
43
43
  */
44
44
  export async function main(options) {
45
+ let statusCode = 0;
45
46
  let currentFile = null;
46
47
  try {
47
48
  const args = parseArgs(options.argv);
@@ -101,7 +102,7 @@ export async function main(options) {
101
102
  // Execute the script
102
103
  const timeBegin = performance.now();
103
104
  // eslint-disable-next-line no-await-in-loop
104
- await executeScriptAsync(script, {
105
+ const result = await executeScriptAsync(script, {
105
106
  'debug': args.debug ?? false,
106
107
  'fetchFn': options.fetchFn,
107
108
  'globals': args.variables,
@@ -110,20 +111,26 @@ export async function main(options) {
110
111
  'urlFn': (url) => (rURL.test(url) || url.startsWith('/') ? url : `${file.slice(0, file.lastIndexOf('/') + 1)}${url}`)
111
112
 
112
113
  });
114
+ statusCode = (Number.isInteger(result) && result >= 0 && result <= 255 ? result : (result ? 1 : 0));
113
115
 
114
116
  // Log script execution end with timing
115
117
  if (args.debug) {
116
118
  const timeEnd = performance.now();
117
119
  options.logFn(`BareScript: Script executed in ${(timeEnd - timeBegin).toFixed(1)} milliseconds`);
118
120
  }
121
+
122
+ // Stop on error status code
123
+ if (statusCode !== 0) {
124
+ break;
125
+ }
119
126
  }
120
127
  } catch ({message}) {
121
128
  const fileStr = (currentFile !== null ? `${currentFile}:\n` : '');
122
129
  options.logFn(`${fileStr}${message}`);
123
- return 1;
130
+ statusCode = 1;
124
131
  }
125
132
 
126
- return 0;
133
+ return statusCode;
127
134
  }
128
135
 
129
136
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "bare-script",
4
- "version": "2.2.3",
4
+ "version": "2.2.4",
5
5
  "description": "BareScript; a lightweight scripting and expression language",
6
6
  "keywords": [
7
7
  "expression",