@idomatic/parser-js 1.0.23 → 1.0.24

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/index.js +8 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -6,7 +6,13 @@ import { createRequire } from "module";
6
6
  const require = createRequire(import.meta.url);
7
7
  const b = types.builders;
8
8
 
9
- export default function parseJS(filePath, config) {
9
+ /**
10
+ * @param {string} filePath - Full path to file
11
+ * @param {object} config - iDomatic config
12
+ * @param {boolean} dry - Whether to skip writing to disk
13
+ * @returns {boolean} - True if the file would be (or was) updated
14
+ */
15
+ export default function parseJS(filePath, config, dry = false) {
10
16
  const code = fs.readFileSync(filePath, "utf-8");
11
17
  let changed = false;
12
18
 
@@ -42,7 +48,7 @@ export default function parseJS(filePath, config) {
42
48
  },
43
49
  });
44
50
 
45
- if (changed) {
51
+ if (changed && !dry) {
46
52
  const output = print(ast).code;
47
53
  fs.writeFileSync(filePath, output);
48
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idomatic/parser-js",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "description": "JS/TSX parser for idomatic CLI",
5
5
  "type": "module",
6
6
  "main": "index.js",