@turingcode/cli 0.2.9 → 0.2.10

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/dist/core/files.js +12 -2
  2. package/package.json +1 -1
@@ -29,10 +29,20 @@ export function readJsonFile(path) {
29
29
  *
30
30
  * @param {string} value - Raw flag value.
31
31
  * @returns {unknown} The parsed JSON.
32
- * @throws {Error} When the file cannot be read or the JSON is invalid.
32
+ * @throws {Error} When the value is neither inline JSON nor an existing file, the file cannot be read, or the JSON is invalid.
33
33
  */
34
34
  export function readJsonArg(value) {
35
- const text = /^\s*[{[]/.test(value) ? value : readFileSync(value, "utf-8");
35
+ let text = value;
36
+ if (!/^\s*[{[]/.test(value)) {
37
+ try {
38
+ text = readFileSync(value, "utf-8");
39
+ }
40
+ catch (e) {
41
+ if (e.code !== "ENOENT")
42
+ throw e;
43
+ throw new Error(`'${value}' is neither inline JSON (starting with {) nor an existing .json file`);
44
+ }
45
+ }
36
46
  try {
37
47
  return JSON.parse(text);
38
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turingcode/cli",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "Turing Code toolkit for AI agents: check Markdown/CSV tables against table contracts, e.g. `turingcode table check`.",
5
5
  "type": "module",
6
6
  "bin": {