bare-script 2.3.0 → 2.3.2

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.
@@ -3,7 +3,7 @@
3
3
  // https://github.com/craigahobbs/bare-script/blob/main/LICENSE
4
4
 
5
5
  import {argv, exit, stdout} from 'node:process';
6
- import {main} from '../lib/bareDoc.js';
6
+ import {main} from '../lib/baredoc.js';
7
7
  import {readFile} from 'node:fs/promises';
8
8
 
9
9
 
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * BareScript library documentation CLI options
7
7
  *
8
- * @typedef {Object} BareDocOptions
8
+ * @typedef {Object} BaredocOptions
9
9
  * @property {string[]} argv - The process command-line arguments
10
10
  * @property {function} fetchFn - The [fetch function]{@link module:lib/runtime~FetchFn}
11
11
  * @property {function} logFn - The [log function]{@link module:lib/runtime~LogFn}
@@ -16,7 +16,7 @@
16
16
  /**
17
17
  * BareScript library documentation command-line interface (CLI) main entry point
18
18
  *
19
- * @param {Object} options - The CLI [options]{@link module:lib/bare~BareDocOptions}
19
+ * @param {Object} options - The CLI [options]{@link module:lib/bare~BaredocOptions}
20
20
  * @returns {Number} The exit code
21
21
  * @ignore
22
22
  */
@@ -45,7 +45,7 @@ export async function main(options) {
45
45
  }
46
46
  return [url, text];
47
47
  }));
48
- options.logFn(JSON.stringify(parseBareDoc(files), null, 4));
48
+ options.logFn(JSON.stringify(parseBaredoc(files)));
49
49
  } catch ({message}) {
50
50
  options.logFn(message);
51
51
  return 1;
@@ -63,7 +63,7 @@ export async function main(options) {
63
63
  * @throws {Error}
64
64
  * @ignore
65
65
  */
66
- export function parseBareDoc(files) {
66
+ export function parseBaredoc(files) {
67
67
  // Parse each source file line-by-line
68
68
  const errors = [];
69
69
  const funcs = {};
package/lib/library.js CHANGED
@@ -888,7 +888,10 @@ function regexReplace([regex, string, substr]) {
888
888
  return null;
889
889
  }
890
890
 
891
- return string.replace(regex, substr);
891
+ // Re-compile the regex with the "g" flag, if necessary
892
+ const regexGlobal = (regex.flags.indexOf('g') !== -1 ? regex : new RegExp(regex.source, `${regex.flags}g`));
893
+
894
+ return string.replaceAll(regexGlobal, substr);
892
895
  }
893
896
 
894
897
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "bare-script",
4
- "version": "2.3.0",
4
+ "version": "2.3.2",
5
5
  "description": "BareScript; a lightweight scripting and expression language",
6
6
  "keywords": [
7
7
  "expression",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "bin": {
20
20
  "bare": "./bin/bare.js",
21
- "baredoc": "./bin/bareDoc.js"
21
+ "baredoc": "./bin/baredoc.js"
22
22
  },
23
23
  "files": [
24
24
  "lib/**/*"