json-to-fs-structure 1.2.13 → 1.3.0

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,35 @@
1
+ import { defineConfig } from "eslint/config";
2
+ import prettier from "eslint-plugin-prettier";
3
+ import globals from "globals";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import js from "@eslint/js";
7
+ import { FlatCompat } from "@eslint/eslintrc";
8
+
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+ const compat = new FlatCompat({
12
+ baseDirectory: __dirname,
13
+ recommendedConfig: js.configs.recommended,
14
+ allConfig: js.configs.all,
15
+ });
16
+
17
+ export default defineConfig([
18
+ {
19
+ extends: compat.extends("plugin:prettier/recommended"),
20
+
21
+ plugins: {
22
+ prettier,
23
+ },
24
+
25
+ languageOptions: {
26
+ globals: {
27
+ ...globals.node,
28
+ },
29
+ },
30
+
31
+ rules: {
32
+ "prettier/prettier": "error",
33
+ },
34
+ },
35
+ ]);
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const fs = require("fs");
2
2
  const { sep } = require("path");
3
3
 
4
- const isLeaf = testNode =>
4
+ const isLeaf = (testNode) =>
5
5
  testNode.constructor === Object && Object.keys(testNode).length === 0;
6
6
 
7
7
  const isEqualOrIsInArray = (property, stopWord) =>
@@ -15,7 +15,7 @@ const levelPropertiesToDirectories = (
15
15
  stopWord,
16
16
  ignoredWords,
17
17
  spaceReplace,
18
- executorObject = {}
18
+ executorObject = {},
19
19
  ) => {
20
20
  if (obj && (typeof obj === "string" || obj instanceof String)) {
21
21
  return;
@@ -25,7 +25,7 @@ const levelPropertiesToDirectories = (
25
25
  let promiseArray = [];
26
26
  let fields = [];
27
27
  if (obj && obj instanceof Array) {
28
- obj.forEach(arrayObject => {
28
+ obj.forEach((arrayObject) => {
29
29
  promiseArray = promiseArray.concat(
30
30
  levelPropertiesToDirectories(
31
31
  arrayObject,
@@ -37,15 +37,15 @@ const levelPropertiesToDirectories = (
37
37
  leafProcedure,
38
38
  nonLeafProcedure,
39
39
  procedure,
40
- accumulator
41
- }
42
- )
40
+ accumulator,
41
+ },
42
+ ),
43
43
  );
44
44
  });
45
45
  } else if (obj) {
46
46
  fields = Object.keys(obj) || [];
47
47
  }
48
- fields.forEach(property => {
48
+ fields.forEach((property) => {
49
49
  if (
50
50
  !isEqualOrIsInArray(property, stopWord) &&
51
51
  ignoredWords.indexOf(property) === -1
@@ -63,7 +63,7 @@ const levelPropertiesToDirectories = (
63
63
  newPath,
64
64
  accumulator,
65
65
  obj[`${property}`],
66
- property
66
+ property,
67
67
  );
68
68
  }
69
69
  if (procedure) {
@@ -71,7 +71,7 @@ const levelPropertiesToDirectories = (
71
71
  newPath,
72
72
  accumulator,
73
73
  obj[`${property}`],
74
- property
74
+ property,
75
75
  );
76
76
  }
77
77
  promiseArray = promiseArray.concat(
@@ -85,9 +85,9 @@ const levelPropertiesToDirectories = (
85
85
  leafProcedure,
86
86
  nonLeafProcedure,
87
87
  procedure,
88
- accumulator: accumulatorCopy
89
- }
90
- )
88
+ accumulator: accumulatorCopy,
89
+ },
90
+ ),
91
91
  );
92
92
  } else {
93
93
  if (leafProcedure && isLeaf(obj[`${property}`])) {
@@ -95,7 +95,7 @@ const levelPropertiesToDirectories = (
95
95
  newPath,
96
96
  Object.assign({}, accumulator),
97
97
  obj[`${property}`],
98
- property
98
+ property,
99
99
  );
100
100
  }
101
101
  if (procedure && isLeaf(obj[`${property}`])) {
@@ -103,7 +103,7 @@ const levelPropertiesToDirectories = (
103
103
  newPath,
104
104
  Object.assign({}, accumulator),
105
105
  obj[`${property}`],
106
- property
106
+ property,
107
107
  );
108
108
  }
109
109
  }
@@ -113,7 +113,7 @@ const levelPropertiesToDirectories = (
113
113
  `${filePath}${sep}`,
114
114
  Object.assign({}, accumulator),
115
115
  obj[`${property}`],
116
- property
116
+ property,
117
117
  );
118
118
  }
119
119
  }
@@ -121,13 +121,13 @@ const levelPropertiesToDirectories = (
121
121
  return promiseArray;
122
122
  };
123
123
 
124
- exports.jsonToFsStructure = function({
124
+ exports.jsonToFsStructure = function ({
125
125
  jsonObject,
126
126
  filePath = ".",
127
127
  callback = () => {},
128
128
  stopWord,
129
129
  spaceReplace,
130
- ignoredWords = []
130
+ ignoredWords = [],
131
131
  }) {
132
132
  return Promise.all(
133
133
  levelPropertiesToDirectories(
@@ -135,12 +135,12 @@ exports.jsonToFsStructure = function({
135
135
  filePath,
136
136
  stopWord,
137
137
  ignoredWords,
138
- spaceReplace
139
- )
138
+ spaceReplace,
139
+ ),
140
140
  ).then(callback);
141
141
  };
142
142
 
143
- exports.jsonToFsWithLeafFunction = function({
143
+ exports.jsonToFsWithLeafFunction = function ({
144
144
  jsonObject,
145
145
  leafProcedure = () => {},
146
146
  context = {},
@@ -148,7 +148,7 @@ exports.jsonToFsWithLeafFunction = function({
148
148
  callback = () => {},
149
149
  stopWord,
150
150
  spaceReplace,
151
- ignoredWords = []
151
+ ignoredWords = [],
152
152
  }) {
153
153
  return Promise.all(
154
154
  levelPropertiesToDirectories(
@@ -159,13 +159,13 @@ exports.jsonToFsWithLeafFunction = function({
159
159
  spaceReplace,
160
160
  {
161
161
  leafProcedure,
162
- accumulator: context
163
- }
164
- )
162
+ accumulator: context,
163
+ },
164
+ ),
165
165
  ).then(callback);
166
166
  };
167
167
 
168
- exports.jsonToFsWithNonLeafFunction = function({
168
+ exports.jsonToFsWithNonLeafFunction = function ({
169
169
  jsonObject,
170
170
  nonLeafProcedure = () => {},
171
171
  context = {},
@@ -173,7 +173,7 @@ exports.jsonToFsWithNonLeafFunction = function({
173
173
  callback = () => {},
174
174
  stopWord,
175
175
  spaceReplace,
176
- ignoredWords = []
176
+ ignoredWords = [],
177
177
  }) {
178
178
  return Promise.all(
179
179
  levelPropertiesToDirectories(
@@ -184,13 +184,13 @@ exports.jsonToFsWithNonLeafFunction = function({
184
184
  spaceReplace,
185
185
  {
186
186
  nonLeafProcedure,
187
- accumulator: context
188
- }
189
- )
187
+ accumulator: context,
188
+ },
189
+ ),
190
190
  ).then(callback);
191
191
  };
192
192
 
193
- exports.jsonToFsWithFunction = function({
193
+ exports.jsonToFsWithFunction = function ({
194
194
  jsonObject,
195
195
  procedure = () => {},
196
196
  context = {},
@@ -198,7 +198,7 @@ exports.jsonToFsWithFunction = function({
198
198
  callback = () => {},
199
199
  stopWord,
200
200
  spaceReplace,
201
- ignoredWords = []
201
+ ignoredWords = [],
202
202
  }) {
203
203
  return Promise.all(
204
204
  levelPropertiesToDirectories(
@@ -209,8 +209,8 @@ exports.jsonToFsWithFunction = function({
209
209
  spaceReplace,
210
210
  {
211
211
  procedure,
212
- accumulator: context
213
- }
214
- )
212
+ accumulator: context,
213
+ },
214
+ ),
215
215
  ).then(callback);
216
216
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-to-fs-structure",
3
- "version": "1.2.13",
3
+ "version": "1.3.0",
4
4
  "description": "A simple module that takes a simple JSON file and produces the properties as a file structure in the same directory or given directory.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -15,12 +15,12 @@
15
15
  "author": "eldavojohn",
16
16
  "license": "MIT",
17
17
  "devDependencies": {
18
- "eslint": "^5.11.1",
19
- "eslint-config-prettier": "^3.3.0",
20
- "eslint-plugin-prettier": "^3.0.0",
21
- "jest": "^24.8.0",
22
- "mocha": "^5.2.0",
23
- "prettier": "^1.9.2"
18
+ "eslint": "^9.39.2",
19
+ "eslint-config-prettier": "^10.1.8",
20
+ "eslint-plugin-prettier": "^5.5.5",
21
+ "jest": "^30.2.0",
22
+ "mocha": "^11.7.5",
23
+ "prettier": "^3.8.1"
24
24
  },
25
25
  "resolutions": {
26
26
  "**/**/cryptiles": "^4.1.2",
@@ -33,5 +33,11 @@
33
33
  "repository": {
34
34
  "type": "git",
35
35
  "url": "https://github.com/eldavojohn/json-to-fs-structure.git"
36
+ },
37
+ "dependencies": {
38
+ "hoek": "^6.1.3",
39
+ "mem": "^10.0.0",
40
+ "minimist": "^1.2.3",
41
+ "npm": "^11.8.0"
36
42
  }
37
- }
43
+ }
@@ -1,7 +1,7 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
1
+ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2
2
 
3
3
  exports[`json-to-fs-structure jsonToFsWithFunction should not do anything with ignored words like meta 1`] = `
4
- Array [
4
+ [
5
5
  "./testArrayField5",
6
6
  "./testArrayField5/somedir",
7
7
  "./testArrayField5/anotherdir",
@@ -12,7 +12,7 @@ Array [
12
12
  `;
13
13
 
14
14
  exports[`json-to-fs-structure jsonToFsWithFunction should not go below the stop word andanotherdir provided 1`] = `
15
- Array [
15
+ [
16
16
  "./testArrayField5",
17
17
  "./testArrayField5/somedir",
18
18
  "./testArrayField5/anotherdir",
@@ -20,7 +20,7 @@ Array [
20
20
  `;
21
21
 
22
22
  exports[`json-to-fs-structure jsonToFsWithFunction should produce a nested deep complex directory structure and execute the procedure on everything 1`] = `
23
- Array [
23
+ [
24
24
  "./testArrayField5",
25
25
  "./testArrayField5/somedir",
26
26
  "./testArrayField5/anotherdir",
@@ -34,7 +34,7 @@ Array [
34
34
  `;
35
35
 
36
36
  exports[`json-to-fs-structure jsonToFsWithLeafFunction should produce a nested deep complex directory structure and execute the procedure on leaves 1`] = `
37
- Array [
37
+ [
38
38
  "./testArrayField5/somedir",
39
39
  "./testArrayField5/anotherdir",
40
40
  "./testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfour",
@@ -43,7 +43,7 @@ Array [
43
43
  `;
44
44
 
45
45
  exports[`json-to-fs-structure jsonToFsWithLeafFunction should produce a nested directory not past a stop word with a leaf function 1`] = `
46
- Array [
46
+ [
47
47
  "./testArrayField5/somedir",
48
48
  "./testArrayField5/anotherdir",
49
49
  "./testArrayField5/andanotherdir/",
@@ -51,7 +51,7 @@ Array [
51
51
  `;
52
52
 
53
53
  exports[`json-to-fs-structure jsonToFsWithNonLeafFunction should produce a nested deep complex directory structure and execute the procedure on non leaves 1`] = `
54
- Array [
54
+ [
55
55
  "./testArrayField5",
56
56
  "./testArrayField5/andanotherdir",
57
57
  "./testArrayField5/andanotherdir/interiorone",
@@ -5,31 +5,31 @@ const {
5
5
  jsonToFsStructure,
6
6
  jsonToFsWithLeafFunction,
7
7
  jsonToFsWithNonLeafFunction,
8
- jsonToFsWithFunction
8
+ jsonToFsWithFunction,
9
9
  } = require("../index");
10
10
 
11
11
  describe("json-to-fs-structure", () => {
12
12
  describe("jsonToFsStructure", () => {
13
- it("should produce a simple directory with a first layer object", done => {
13
+ it("should produce a simple directory with a first layer object", (done) => {
14
14
  const options = {
15
15
  jsonObject: {
16
- testDirectoryField: {}
16
+ testDirectoryField: {},
17
17
  },
18
18
  filePath: ".",
19
19
  callback: () => {
20
20
  assert.equal(fs.statSync("testDirectoryField").size, 4096);
21
21
  fs.rmdirSync("testDirectoryField");
22
22
  done();
23
- }
23
+ },
24
24
  };
25
25
  jsonToFsStructure(options);
26
26
  });
27
- it("should produce a simple directory with a first layer object with siblings", done => {
27
+ it("should produce a simple directory with a first layer object with siblings", (done) => {
28
28
  const options = {
29
29
  jsonObject: {
30
30
  testDirectoryField0: {},
31
31
  testDirectoryField1: {},
32
- testDirectoryField2: {}
32
+ testDirectoryField2: {},
33
33
  },
34
34
  filePath: ".",
35
35
  callback: () => {
@@ -40,36 +40,36 @@ describe("json-to-fs-structure", () => {
40
40
  fs.rmdirSync("testDirectoryField1");
41
41
  fs.rmdirSync("testDirectoryField2");
42
42
  done();
43
- }
43
+ },
44
44
  };
45
45
  jsonToFsStructure(options);
46
46
  });
47
- it("should produce a nested directory structure", done => {
47
+ it("should produce a nested directory structure", (done) => {
48
48
  const options = {
49
49
  jsonObject: {
50
- testDirectoryField3: { innerTestField: {} }
50
+ testDirectoryField3: { innerTestField: {} },
51
51
  },
52
52
  filePath: ".",
53
53
  callback: () => {
54
54
  assert.equal(
55
55
  fs.statSync("testDirectoryField3/innerTestField").size,
56
- 4096
56
+ 4096,
57
57
  );
58
58
  fs.rmdirSync("testDirectoryField3/innerTestField");
59
59
  fs.rmdirSync("testDirectoryField3");
60
60
  done();
61
- }
61
+ },
62
62
  };
63
63
  jsonToFsStructure(options);
64
64
  });
65
- it("should produce a nested directory structure when there is an array of strings", done => {
65
+ it("should produce a nested directory structure when there is an array of strings", (done) => {
66
66
  const options = {
67
67
  jsonObject: {
68
68
  testArrayField5: [
69
69
  { somedir: {} },
70
70
  { anotherdir: {} },
71
- { andanotherdir: {} }
72
- ]
71
+ { andanotherdir: {} },
72
+ ],
73
73
  },
74
74
  filePath: ".",
75
75
  callback: () => {
@@ -81,11 +81,11 @@ describe("json-to-fs-structure", () => {
81
81
  fs.rmdirSync("testArrayField5/andanotherdir");
82
82
  fs.rmdirSync("testArrayField5");
83
83
  done();
84
- }
84
+ },
85
85
  };
86
86
  jsonToFsStructure(options);
87
87
  });
88
- it("should produce a nested deep complex directory structure", done => {
88
+ it("should produce a nested deep complex directory structure", (done) => {
89
89
  const options = {
90
90
  jsonObject: {
91
91
  testArrayField5: [
@@ -95,12 +95,12 @@ describe("json-to-fs-structure", () => {
95
95
  andanotherdir: {
96
96
  interiorone: {
97
97
  interiortwo: {
98
- interiorthree: [{ interiorfour: {} }, { interiorfive: {} }]
99
- }
100
- }
101
- }
102
- }
103
- ]
98
+ interiorthree: [{ interiorfour: {} }, { interiorfive: {} }],
99
+ },
100
+ },
101
+ },
102
+ },
103
+ ],
104
104
  },
105
105
  filePath: ".",
106
106
  callback: () => {
@@ -109,54 +109,54 @@ describe("json-to-fs-structure", () => {
109
109
  assert.equal(fs.statSync("testArrayField5/andanotherdir").size, 4096);
110
110
  assert.equal(
111
111
  fs.statSync("testArrayField5/andanotherdir/interiorone").size,
112
- 4096
112
+ 4096,
113
113
  );
114
114
  assert.equal(
115
115
  fs.statSync("testArrayField5/andanotherdir/interiorone/interiortwo")
116
116
  .size,
117
- 4096
117
+ 4096,
118
118
  );
119
119
  assert.equal(
120
120
  fs.statSync(
121
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree"
121
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree",
122
122
  ).size,
123
- 4096
123
+ 4096,
124
124
  );
125
125
  assert.equal(
126
126
  fs.statSync(
127
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfour"
127
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfour",
128
128
  ).size,
129
- 4096
129
+ 4096,
130
130
  );
131
131
  assert.equal(
132
132
  fs.statSync(
133
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfive"
133
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfive",
134
134
  ).size,
135
- 4096
135
+ 4096,
136
136
  );
137
137
  fs.rmdirSync("testArrayField5/somedir");
138
138
  fs.rmdirSync("testArrayField5/anotherdir");
139
139
  fs.rmdirSync(
140
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfive"
140
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfive",
141
141
  );
142
142
  fs.rmdirSync(
143
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfour"
143
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfour",
144
144
  );
145
145
  fs.rmdirSync(
146
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree"
146
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree",
147
147
  );
148
148
  fs.rmdirSync("testArrayField5/andanotherdir/interiorone/interiortwo");
149
149
  fs.rmdirSync("testArrayField5/andanotherdir/interiorone");
150
150
  fs.rmdirSync("testArrayField5/andanotherdir");
151
151
  fs.rmdirSync("testArrayField5");
152
152
  done();
153
- }
153
+ },
154
154
  };
155
155
  jsonToFsStructure(options);
156
156
  });
157
157
  });
158
158
  describe("jsonToFsWithLeafFunction", () => {
159
- it("should produce a nested deep complex directory structure and execute the procedure on leaves", done => {
159
+ it("should produce a nested deep complex directory structure and execute the procedure on leaves", (done) => {
160
160
  const endpoints = [];
161
161
  const options = {
162
162
  jsonObject: {
@@ -167,12 +167,12 @@ describe("json-to-fs-structure", () => {
167
167
  andanotherdir: {
168
168
  interiorone: {
169
169
  interiortwo: {
170
- interiorthree: [{ interiorfour: {} }, { interiorfive: {} }]
171
- }
172
- }
173
- }
174
- }
175
- ]
170
+ interiorthree: [{ interiorfour: {} }, { interiorfive: {} }],
171
+ },
172
+ },
173
+ },
174
+ },
175
+ ],
176
176
  },
177
177
  filePath: ".",
178
178
  leafProcedure: (filePath, acc) => {
@@ -184,53 +184,53 @@ describe("json-to-fs-structure", () => {
184
184
  assert.equal(fs.statSync("testArrayField5/andanotherdir").size, 4096);
185
185
  assert.equal(
186
186
  fs.statSync("testArrayField5/andanotherdir/interiorone").size,
187
- 4096
187
+ 4096,
188
188
  );
189
189
  assert.equal(
190
190
  fs.statSync("testArrayField5/andanotherdir/interiorone/interiortwo")
191
191
  .size,
192
- 4096
192
+ 4096,
193
193
  );
194
194
  assert.equal(
195
195
  fs.statSync(
196
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree"
196
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree",
197
197
  ).size,
198
- 4096
198
+ 4096,
199
199
  );
200
200
  assert.equal(
201
201
  fs.statSync(
202
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfour"
202
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfour",
203
203
  ).size,
204
- 4096
204
+ 4096,
205
205
  );
206
206
  assert.equal(
207
207
  fs.statSync(
208
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfive"
208
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfive",
209
209
  ).size,
210
- 4096
210
+ 4096,
211
211
  );
212
212
  fs.rmdirSync("testArrayField5/somedir");
213
213
  fs.rmdirSync("testArrayField5/anotherdir");
214
214
  fs.rmdirSync(
215
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfive"
215
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfive",
216
216
  );
217
217
  fs.rmdirSync(
218
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfour"
218
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfour",
219
219
  );
220
220
  fs.rmdirSync(
221
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree"
221
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree",
222
222
  );
223
223
  fs.rmdirSync("testArrayField5/andanotherdir/interiorone/interiortwo");
224
224
  fs.rmdirSync("testArrayField5/andanotherdir/interiorone");
225
225
  fs.rmdirSync("testArrayField5/andanotherdir");
226
226
  fs.rmdirSync("testArrayField5");
227
227
  done();
228
- }
228
+ },
229
229
  };
230
230
  jsonToFsWithLeafFunction(options);
231
231
  expect(endpoints).toMatchSnapshot();
232
232
  });
233
- it("should produce a nested directory not past a stop word with a leaf function", done => {
233
+ it("should produce a nested directory not past a stop word with a leaf function", (done) => {
234
234
  const endpoints = [];
235
235
  const options = {
236
236
  jsonObject: {
@@ -241,12 +241,12 @@ describe("json-to-fs-structure", () => {
241
241
  andanotherdir: {
242
242
  interiorone: {
243
243
  interiortwo: {
244
- interiorthree: [{ interiorfour: {} }, { interiorfive: {} }]
245
- }
246
- }
247
- }
248
- }
249
- ]
244
+ interiorthree: [{ interiorfour: {} }, { interiorfive: {} }],
245
+ },
246
+ },
247
+ },
248
+ },
249
+ ],
250
250
  },
251
251
  leafProcedure: (filePath, acc) => {
252
252
  endpoints.push(filePath);
@@ -262,14 +262,14 @@ describe("json-to-fs-structure", () => {
262
262
  fs.rmdirSync("testArrayField5");
263
263
  done();
264
264
  },
265
- stopWord: "interiorone"
265
+ stopWord: "interiorone",
266
266
  };
267
267
  jsonToFsWithLeafFunction(options);
268
268
  expect(endpoints).toMatchSnapshot();
269
269
  });
270
270
  });
271
271
  describe("jsonToFsWithNonLeafFunction", () => {
272
- it("should produce a nested deep complex directory structure and execute the procedure on non leaves", done => {
272
+ it("should produce a nested deep complex directory structure and execute the procedure on non leaves", (done) => {
273
273
  const endpoints = [];
274
274
  const options = {
275
275
  jsonObject: {
@@ -280,12 +280,12 @@ describe("json-to-fs-structure", () => {
280
280
  andanotherdir: {
281
281
  interiorone: {
282
282
  interiortwo: {
283
- interiorthree: [{ interiorfour: {} }, { interiorfive: {} }]
284
- }
285
- }
286
- }
287
- }
288
- ]
283
+ interiorthree: [{ interiorfour: {} }, { interiorfive: {} }],
284
+ },
285
+ },
286
+ },
287
+ },
288
+ ],
289
289
  },
290
290
  nonLeafProcedure: (filePath, acc) => {
291
291
  endpoints.push(filePath);
@@ -298,55 +298,55 @@ describe("json-to-fs-structure", () => {
298
298
  assert.equal(fs.statSync("testArrayField5/andanotherdir").size, 4096);
299
299
  assert.equal(
300
300
  fs.statSync("testArrayField5/andanotherdir/interiorone").size,
301
- 4096
301
+ 4096,
302
302
  );
303
303
  assert.equal(
304
304
  fs.statSync("testArrayField5/andanotherdir/interiorone/interiortwo")
305
305
  .size,
306
- 4096
306
+ 4096,
307
307
  );
308
308
  assert.equal(
309
309
  fs.statSync(
310
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree"
310
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree",
311
311
  ).size,
312
- 4096
312
+ 4096,
313
313
  );
314
314
  assert.equal(
315
315
  fs.statSync(
316
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfour"
316
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfour",
317
317
  ).size,
318
- 4096
318
+ 4096,
319
319
  );
320
320
  assert.equal(
321
321
  fs.statSync(
322
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfive"
322
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfive",
323
323
  ).size,
324
- 4096
324
+ 4096,
325
325
  );
326
326
  fs.rmdirSync("testArrayField5/somedir");
327
327
  fs.rmdirSync("testArrayField5/anotherdir");
328
328
  fs.rmdirSync(
329
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfive"
329
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfive",
330
330
  );
331
331
  fs.rmdirSync(
332
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfour"
332
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfour",
333
333
  );
334
334
  fs.rmdirSync(
335
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree"
335
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree",
336
336
  );
337
337
  fs.rmdirSync("testArrayField5/andanotherdir/interiorone/interiortwo");
338
338
  fs.rmdirSync("testArrayField5/andanotherdir/interiorone");
339
339
  fs.rmdirSync("testArrayField5/andanotherdir");
340
340
  fs.rmdirSync("testArrayField5");
341
341
  done();
342
- }
342
+ },
343
343
  };
344
344
  jsonToFsWithNonLeafFunction(options);
345
345
  expect(endpoints).toMatchSnapshot();
346
346
  });
347
347
  });
348
348
  describe("jsonToFsWithFunction", () => {
349
- it("should produce a nested deep complex directory structure and execute the procedure on everything", done => {
349
+ it("should produce a nested deep complex directory structure and execute the procedure on everything", (done) => {
350
350
  const endpoints = [];
351
351
  const options = {
352
352
  jsonObject: {
@@ -357,12 +357,12 @@ describe("json-to-fs-structure", () => {
357
357
  andanotherdir: {
358
358
  interiorone: {
359
359
  interiortwo: {
360
- interiorthree: [{ interiorfour: {} }, { interiorfive: {} }]
361
- }
362
- }
363
- }
364
- }
365
- ]
360
+ interiorthree: [{ interiorfour: {} }, { interiorfive: {} }],
361
+ },
362
+ },
363
+ },
364
+ },
365
+ ],
366
366
  },
367
367
  procedure: (filePath, acc) => {
368
368
  endpoints.push(filePath);
@@ -375,53 +375,53 @@ describe("json-to-fs-structure", () => {
375
375
  assert.equal(fs.statSync("testArrayField5/andanotherdir").size, 4096);
376
376
  assert.equal(
377
377
  fs.statSync("testArrayField5/andanotherdir/interiorone").size,
378
- 4096
378
+ 4096,
379
379
  );
380
380
  assert.equal(
381
381
  fs.statSync("testArrayField5/andanotherdir/interiorone/interiortwo")
382
382
  .size,
383
- 4096
383
+ 4096,
384
384
  );
385
385
  assert.equal(
386
386
  fs.statSync(
387
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree"
387
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree",
388
388
  ).size,
389
- 4096
389
+ 4096,
390
390
  );
391
391
  assert.equal(
392
392
  fs.statSync(
393
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfour"
393
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfour",
394
394
  ).size,
395
- 4096
395
+ 4096,
396
396
  );
397
397
  assert.equal(
398
398
  fs.statSync(
399
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfive"
399
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfive",
400
400
  ).size,
401
- 4096
401
+ 4096,
402
402
  );
403
403
  fs.rmdirSync("testArrayField5/somedir");
404
404
  fs.rmdirSync("testArrayField5/anotherdir");
405
405
  fs.rmdirSync(
406
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfive"
406
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfive",
407
407
  );
408
408
  fs.rmdirSync(
409
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfour"
409
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree/interiorfour",
410
410
  );
411
411
  fs.rmdirSync(
412
- "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree"
412
+ "testArrayField5/andanotherdir/interiorone/interiortwo/interiorthree",
413
413
  );
414
414
  fs.rmdirSync("testArrayField5/andanotherdir/interiorone/interiortwo");
415
415
  fs.rmdirSync("testArrayField5/andanotherdir/interiorone");
416
416
  fs.rmdirSync("testArrayField5/andanotherdir");
417
417
  fs.rmdirSync("testArrayField5");
418
418
  done();
419
- }
419
+ },
420
420
  };
421
421
  jsonToFsWithFunction(options);
422
422
  expect(endpoints).toMatchSnapshot();
423
423
  });
424
- it("should not go below the stop word andanotherdir provided", done => {
424
+ it("should not go below the stop word andanotherdir provided", (done) => {
425
425
  const endpoints = [];
426
426
  const options = {
427
427
  jsonObject: {
@@ -432,12 +432,12 @@ describe("json-to-fs-structure", () => {
432
432
  andanotherdir: {
433
433
  interiorone: {
434
434
  interiortwo: {
435
- interiorthree: [{ interiorfour: {} }, { interiorfive: {} }]
436
- }
437
- }
438
- }
439
- }
440
- ]
435
+ interiorthree: [{ interiorfour: {} }, { interiorfive: {} }],
436
+ },
437
+ },
438
+ },
439
+ },
440
+ ],
441
441
  },
442
442
  procedure: (filePath, acc) => {
443
443
  endpoints.push(filePath);
@@ -452,12 +452,12 @@ describe("json-to-fs-structure", () => {
452
452
  fs.rmdirSync("testArrayField5");
453
453
  done();
454
454
  },
455
- stopWord: "andanotherdir"
455
+ stopWord: "andanotherdir",
456
456
  };
457
457
  jsonToFsWithFunction(options);
458
458
  expect(endpoints).toMatchSnapshot();
459
459
  });
460
- it("should not do anything with ignored words like meta", done => {
460
+ it("should not do anything with ignored words like meta", (done) => {
461
461
  const endpoints = [];
462
462
  const options = {
463
463
  jsonObject: {
@@ -470,12 +470,12 @@ describe("json-to-fs-structure", () => {
470
470
  interiorone: {
471
471
  interiortwo: {
472
472
  apple: { dontdonothing: {} },
473
- interiorthree: [{ interiorfour: {} }, { interiorfive: {} }]
474
- }
475
- }
476
- }
477
- }
478
- ]
473
+ interiorthree: [{ interiorfour: {} }, { interiorfive: {} }],
474
+ },
475
+ },
476
+ },
477
+ },
478
+ ],
479
479
  },
480
480
  procedure: (filePath, acc) => {
481
481
  endpoints.push(filePath);
@@ -488,12 +488,12 @@ describe("json-to-fs-structure", () => {
488
488
  assert.equal(fs.statSync("testArrayField5/andanotherdir").size, 4096);
489
489
  assert.equal(
490
490
  fs.statSync("testArrayField5/andanotherdir/interiorone").size,
491
- 4096
491
+ 4096,
492
492
  );
493
493
  assert.equal(
494
494
  fs.statSync("testArrayField5/andanotherdir/interiorone/interiortwo")
495
495
  .size,
496
- 4096
496
+ 4096,
497
497
  );
498
498
  fs.rmdirSync("testArrayField5/somedir");
499
499
  fs.rmdirSync("testArrayField5/anotherdir");
@@ -504,7 +504,7 @@ describe("json-to-fs-structure", () => {
504
504
  done();
505
505
  },
506
506
  ignoredWords: ["meta", "apple"],
507
- stopWord: "interiorthree"
507
+ stopWord: "interiorthree",
508
508
  };
509
509
  jsonToFsWithFunction(options);
510
510
  expect(endpoints).toMatchSnapshot();
package/.eslintrc.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "plugins": ["prettier"],
3
- "rules": {
4
- "prettier/prettier": "error"
5
- },
6
- "extends": [
7
- "plugin:prettier/recommended"
8
- ],
9
- "env": {
10
- "es6": true,
11
- "node": true
12
- }
13
- }