json-instruction-single 1.5.2 → 1.5.3

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/package.json +2 -2
  2. package/src/v5/index.js +57 -57
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-instruction-single",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "exports": {
@@ -17,4 +17,4 @@
17
17
  "json-write-path": "^1.3.2",
18
18
  "spec-repo": "^1.4.2"
19
19
  }
20
- }
20
+ }
package/src/v5/index.js CHANGED
@@ -1,57 +1,57 @@
1
- import applyTemplate from "json-transformer-funcs-primitive";
2
- import fromCollection from "json-transformer-funcs-one-dimension";
3
-
4
- import writePath from "json-write-path";
5
- import resolvePath from "json-source-path";
6
-
7
- import fallbackSpec from "spec-repo";
8
-
9
- const functions = { applyTemplate, fromCollection };
10
-
11
- const getSource = (instruction, registry, showLog) => {
12
- if (instruction?.sourcePath === null) {
13
- return null;
14
- };
15
-
16
- return resolvePath(registry, instruction.sourcePath);
17
- };
18
-
19
- const runSingleInstruction = (instruction, registry, showLog) => {
20
- // Prefer the caller's specification. This lets a renderer provide
21
- // its own templates without coupling the runner to a global spec package.
22
- const localSpec = registry?.spec ?? fallbackSpec;
23
- const localTemplateKey = instruction.templateKey;
24
- const localFunc = instruction?.func;
25
-
26
- const template = localSpec[localTemplateKey];
27
-
28
- const source = getSource(instruction, registry, showLog);
29
-
30
- const localFuncResult = localFunc === null
31
- ? template
32
- : functions[instruction.func](source, template);
33
-
34
- // console.log("111111111 ----: ", localFuncResult, localFunc, template);
35
-
36
-
37
- const result = source === null
38
- ? template
39
- : localFuncResult;
40
-
41
- // console.log("runSingleInstruction ----: ", source, result, localFunc, template, localTemplateKey, localSpec);
42
-
43
- writePath(registry, instruction.destinationPath, result);
44
- };
45
-
46
- const startFunc = (instructions, registry, showLog, returnLog) => {
47
- // console.log("instructions: ", instructions[0]);
48
-
49
-
50
- instructions.forEach(instruction => {
51
- // console.log("instruction ----: ", instruction?.sourcePath, instruction?.templateKey);
52
-
53
- runSingleInstruction(instruction, registry, showLog, returnLog);
54
- });
55
- };
56
-
57
- export default startFunc;
1
+ import applyTemplate from "json-transformer-funcs-primitive";
2
+ import fromCollection from "json-transformer-funcs-one-dimension";
3
+
4
+ import writePath from "json-write-path";
5
+ import resolvePath from "json-source-path";
6
+
7
+ import fallbackSpec from "spec-repo";
8
+
9
+ const functions = { applyTemplate, fromCollection };
10
+
11
+ const getSource = (instruction, registry, showLog) => {
12
+ if (instruction?.sourcePath === null) {
13
+ return null;
14
+ };
15
+
16
+ return resolvePath(registry, instruction.sourcePath);
17
+ };
18
+
19
+ const runSingleInstruction = (instruction, registry, showLog) => {
20
+ // Prefer the caller's specification. This lets a renderer provide
21
+ // its own templates without coupling the runner to a global spec package.
22
+ const localSpec = registry?.spec ?? fallbackSpec;
23
+ const localTemplateKey = instruction.templateKey;
24
+ const localFunc = instruction?.func;
25
+
26
+ const template = localSpec[localTemplateKey];
27
+
28
+ const source = getSource(instruction, registry, showLog);
29
+
30
+ const localFuncResult = localFunc === null
31
+ ? template
32
+ : functions[instruction.func](source, template);
33
+
34
+ // console.log("111111111 ----: ", localFuncResult, localFunc, template);
35
+
36
+
37
+ const result = source === null
38
+ ? template
39
+ : localFuncResult;
40
+
41
+ // console.log("runSingleInstruction ----: ", source, result, localFunc, template, localTemplateKey, localSpec);
42
+
43
+ writePath(registry, instruction.destinationPath, result);
44
+ };
45
+
46
+ const startFunc = (instructions, registry, showLog, returnLog) => {
47
+ // console.log("instructions: ", instructions[0]);
48
+
49
+
50
+ instructions.forEach(instruction => {
51
+ // console.log("instruction ----: ", instruction?.sourcePath, instruction?.templateKey);
52
+
53
+ runSingleInstruction(instruction, registry, showLog, returnLog);
54
+ });
55
+ };
56
+
57
+ export default startFunc;