express-fix-any-js 1.32.21 → 1.32.22

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.
@@ -0,0 +1,48 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { fileNamesJson as fromNpm } from "pattern-collector-base-files";
4
+
5
+ // import fileNamesJson from '../fileNames.json' with {type: 'json'};
6
+
7
+ const startFunc = ({ alterArray, inFileType, inTargetPath, inValue }) => {
8
+
9
+ try {
10
+
11
+ const fileNamesJson = fromNpm();
12
+
13
+ if (!(inFileType in fileNamesJson)) {
14
+ return false;
15
+ };
16
+
17
+ if (!("hookTo" in fileNamesJson[inFileType])) {
18
+ return false;
19
+ };
20
+ // console.log("lllllllllllll : ", fileNamesJson[inFileType]);
21
+
22
+ if (!("fileName" in fileNamesJson[fileNamesJson[inFileType]?.hookTo])) {
23
+ return false;
24
+ };
25
+
26
+ const jsFileName = fileNamesJson[fileNamesJson[inFileType]?.hookTo]?.fileName;
27
+
28
+ const localJsPath = path.join(inTargetPath, inValue, jsFileName);
29
+
30
+ let fileContent = fs.readFileSync(localJsPath, 'utf8');
31
+
32
+ if (alterArray) {
33
+ alterArray.forEach(element => {
34
+ fileContent = fileContent.replaceAll(element.key, element.value);
35
+ });
36
+ };
37
+
38
+ fs.writeFileSync(localJsPath, fileContent);
39
+
40
+ return true;
41
+
42
+ } catch (error) {
43
+ console.log("error : ", error);
44
+
45
+ };
46
+ };
47
+
48
+ export default startFunc;
@@ -23,9 +23,11 @@ const startFunc = ({ alterArray, inFileType, inTargetPath, inValue }) => {
23
23
  return false;
24
24
  };
25
25
 
26
- const jsFileName = fileNamesJson[fileNamesJson[inFileType]?.hookTo]?.fileName;
26
+ const localFileName = fileNamesJson[fileNamesJson[inFileType]?.hookTo]?.fileName;
27
27
 
28
- const localJsPath = path.join(inTargetPath, inValue, jsFileName);
28
+ const localJsPath = path.join(inTargetPath, inValue, localFileName);
29
+
30
+ // console.log("lllllllllllll : ", localJsPath, localJsPath);
29
31
 
30
32
  let fileContent = fs.readFileSync(localJsPath, 'utf8');
31
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-fix-any-js",
3
- "version": "1.32.21",
3
+ "version": "1.32.22",
4
4
  "description": "CLI to build for appjs, the endpoints",
5
5
  "keywords": [
6
6
  "cli",