file-obj-queue 3.0.0 → 3.0.1

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 (50) hide show
  1. package/.github/workflows/{github-actions.yml → github-actions-demo.yml} +1 -1
  2. package/.github/workflows/node.js.yml +0 -1
  3. package/LICENSE +1 -1
  4. package/README.md +7 -132
  5. package/app.js +40 -155
  6. package/base_queue/app.js +146 -0
  7. package/base_queue/appenders/base.js +77 -0
  8. package/base_queue/appenders/json_all.js +70 -0
  9. package/package.json +7 -28
  10. package/test/app.js +1 -5
  11. package/test/package.js +7 -28
  12. package/tests/appenders/all.js +1 -1
  13. package/tests/appenders/base.js +1 -1
  14. package/tests/appenders/bottom_one.js +1 -1
  15. package/tests/appenders/func_all.js +1 -1
  16. package/tests/appenders/sync.js +1 -1
  17. package/tests/appenders/sync_all.js +1 -1
  18. package/tests/appenders/top_one.js +1 -1
  19. package/tests/appenders/version.js +1 -1
  20. package/tests/files.js +32 -50
  21. package/lib/appenders/all.js +0 -17
  22. package/lib/appenders/base.js +0 -189
  23. package/lib/appenders/bottom_one.js +0 -17
  24. package/lib/appenders/func_all.js +0 -17
  25. package/lib/appenders/name.js +0 -17
  26. package/lib/appenders/status.js +0 -17
  27. package/lib/appenders/sync.js +0 -17
  28. package/lib/appenders/sync_all.js +0 -17
  29. package/lib/appenders/top_one.js +0 -17
  30. package/lib/appenders/version.js +0 -17
  31. package/tests/all.js +0 -85
  32. package/tests/bottom_one.js +0 -86
  33. package/tests/func_all.js +0 -94
  34. package/tests/json_all.js +0 -107
  35. package/tests/json_bottom_one.js +0 -108
  36. package/tests/json_func_all.js +0 -109
  37. package/tests/json_name_matching.js +0 -109
  38. package/tests/json_name_non_matching.js +0 -109
  39. package/tests/json_status_matching.js +0 -110
  40. package/tests/json_status_non_matching.js +0 -110
  41. package/tests/json_top_one.js +0 -108
  42. package/tests/json_version_matching.js +0 -110
  43. package/tests/json_version_non_matching.js +0 -110
  44. package/tests/name_matching.js +0 -90
  45. package/tests/name_non_matching.js +0 -90
  46. package/tests/status_matching.js +0 -90
  47. package/tests/status_non_matching.js +0 -90
  48. package/tests/top_one.js +0 -85
  49. package/tests/version_matching.js +0 -90
  50. package/tests/version_non_matching.js +0 -90
@@ -1,109 +0,0 @@
1
- var file_queue = require("../app.js"),
2
- fs = require('fs'),
3
- validPath = require('valid-path')
4
-
5
- var file_data = [
6
- { props: { id: 100, name: "all", status: "new", absolute_path: __filename, check: true } },
7
- { props: { id: 101, name: "func_all", status: "done", absolute_path: __filename, check: true } },
8
- { props: { id: 102, name: "top_one", status: "new", absolute_path: __filename, check: true } },
9
- { props: { id: 103, name: "bottom_one", status: "new", absolute_path: __filename, check: true } },
10
- { props: { id: 104, name: "sync_all", status: "done", absolute_path: __filename, check: true } },
11
- { props: { id: 105, name: "status", status: "delete", absolute_path: __filename, check: true } },
12
- { props: { id: 106, name: "name", status: "test", absolute_path: __filename, check: true } },
13
- { props: { id: 107, name: "version", status: "new", absolute_path: __filename, check: true } }
14
- ]
15
-
16
- var file_object = class file_obj {
17
- constructor(props) {
18
- let t = this, fname = "file_obj.constructor"
19
- try {
20
- t.id = props.id
21
- t.log = props.log
22
- t.name = props.name
23
- t.status = props.status
24
- t.path = props.relative_path
25
- t.absolute_path = props.absolute_path
26
- t.errors = false
27
- t.error_msg = 'none'
28
-
29
- // if (t.id == 104) {
30
- // t.errors = true
31
- // t.error_msg = `some sort of error here`
32
- // }
33
- t.base_queue_process_function = t.a_cool_function
34
-
35
- t.do_checks = t.do_checks.bind(t)
36
- t.a_cool_function = t.a_cool_function.bind(t)
37
- t.base_queue_process_function = t.base_queue_process_function.bind(t)
38
-
39
- if (props.check) {
40
- t.do_checks()
41
- }
42
- } catch (e) {
43
- e.message = `${fname} error: ${e.message}`
44
- throw e
45
- }
46
-
47
- return t
48
- }
49
-
50
- do_checks() {
51
- let t = this, path_to_check,
52
- last_item = t.absolute_path.split("\\").pop(),
53
- check_file = t.absolute_path.split(last_item)[0], check_path = t.path.split('/')
54
-
55
- check_file = check_file.replace(/\\/g, "/");
56
- path_to_check = validPath(t.path);
57
-
58
- if (!path_to_check.valid) {
59
- t.errors = true
60
- t.error_msg = `id = ${t.id} name(${t.name}) Error in ${path_to_check.data.input}: ${path_to_check.error})`
61
- }
62
-
63
- check_path.map((dat, i) => {
64
- if (/^[a-zA-Z._]+$/.test(dat)) {
65
- if (dat != '.')
66
- check_file += dat + '/'
67
- }
68
- })
69
- check_file = check_file.slice(0, -1)
70
- try {
71
- if (!fs.existsSync(check_file)) {
72
- t.errors = true
73
- t.error_msg = `id = ${t.id} name(${t.name}) file (${check_file} does not exist)`
74
- }
75
- } catch (e) {
76
- e.message = "file_obj do_checks error: " + e.message
77
- throw (e)
78
- }
79
- }
80
-
81
- a_cool_function(callback) {
82
- let t = this
83
- t.log({ msg: `processing object id ${t.id} name(${t.name}) status(${t.status}). Do a bunch of stuff here.`.silly, type: "silly" })
84
- if (t.errors)
85
- callback({ error: { msg: t.error_msg } })
86
- else
87
- callback({ success: { msg: `id = ${t.id} name(${t.name}) status(${t.status})`}})
88
- }
89
- }
90
-
91
- var qRequire = new file_queue()
92
-
93
- qRequire.init().process({
94
- appender: "json_name",
95
- exclude_logMsg: ["debug", "silly", "info"], /* default [] */
96
- process_objects: [file_object],
97
- include_names: ["all", "status", "version"],
98
- data_to_process_array: file_data
99
- }).then((success) => {
100
- qRequire.logMsg({ msg: `test success: json name matching objects processed with no errors`.success.italic.bold, type: "success" })
101
- }, (error) => {
102
- if (typeof error == "string") {
103
- qRequire.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
104
- } else {
105
- let add_s = (error.error_count > 1) ? 's' : ''
106
- qRequire.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
107
- }
108
- })
109
-
@@ -1,109 +0,0 @@
1
- var file_queue = require("../app.js"),
2
- fs = require('fs'),
3
- validPath = require('valid-path')
4
-
5
- var file_data = [
6
- { props: { id: 100, name: "all", status: "new", absolute_path: __filename, check: true } },
7
- { props: { id: 101, name: "func_all", status: "done", absolute_path: __filename, check: true } },
8
- { props: { id: 102, name: "top_one", status: "new", absolute_path: __filename, check: true } },
9
- { props: { id: 103, name: "bottom_one", status: "new", absolute_path: __filename, check: true } },
10
- { props: { id: 104, name: "sync_all", status: "done", absolute_path: __filename, check: true } },
11
- { props: { id: 105, name: "status", status: "delete", absolute_path: __filename, check: true } },
12
- { props: { id: 106, name: "name", status: "test", absolute_path: __filename, check: true } },
13
- { props: { id: 107, name: "version", status: "new", absolute_path: __filename, check: true } }
14
- ]
15
-
16
- var file_object = class file_obj {
17
- constructor(props) {
18
- let t = this, fname = "file_obj.constructor"
19
- try {
20
- t.id = props.id
21
- t.log = props.log
22
- t.name = props.name
23
- t.status = props.status
24
- t.path = props.relative_path
25
- t.absolute_path = props.absolute_path
26
- t.errors = false
27
- t.error_msg = 'none'
28
-
29
- // if (t.id == 104) {
30
- // t.errors = true
31
- // t.error_msg = `some sort of error here`
32
- // }
33
- t.base_queue_process_function = t.a_cool_function
34
-
35
- t.do_checks = t.do_checks.bind(t)
36
- t.a_cool_function = t.a_cool_function.bind(t)
37
- t.base_queue_process_function = t.base_queue_process_function.bind(t)
38
-
39
- if (props.check) {
40
- t.do_checks()
41
- }
42
- } catch (e) {
43
- e.message = `${fname} error: ${e.message}`
44
- throw e
45
- }
46
-
47
- return t
48
- }
49
-
50
- do_checks() {
51
- let t = this, path_to_check,
52
- last_item = t.absolute_path.split("\\").pop(),
53
- check_file = t.absolute_path.split(last_item)[0], check_path = t.path.split('/')
54
-
55
- check_file = check_file.replace(/\\/g, "/");
56
- path_to_check = validPath(t.path);
57
-
58
- if (!path_to_check.valid) {
59
- t.errors = true
60
- t.error_msg = `id = ${t.id} name(${t.name}) Error in ${path_to_check.data.input}: ${path_to_check.error})`
61
- }
62
-
63
- check_path.map((dat, i) => {
64
- if (/^[a-zA-Z._]+$/.test(dat)) {
65
- if (dat != '.')
66
- check_file += dat + '/'
67
- }
68
- })
69
- check_file = check_file.slice(0, -1)
70
- try {
71
- if (!fs.existsSync(check_file)) {
72
- t.errors = true
73
- t.error_msg = `id = ${t.id} name(${t.name}) file (${check_file} does not exist)`
74
- }
75
- } catch (e) {
76
- e.message = "file_obj do_checks error: " + e.message
77
- throw (e)
78
- }
79
- }
80
-
81
- a_cool_function(callback) {
82
- let t = this
83
- t.log({ msg: `processing object id ${t.id} name(${t.name}) status(${t.status}). Do a bunch of stuff here.`.silly, type: "silly" })
84
- if (t.errors)
85
- callback({ error: { msg: t.error_msg } })
86
- else
87
- callback({ success: { msg: `id = ${t.id} name(${t.name}) status(${t.status})`}})
88
- }
89
- }
90
-
91
- var qRequire = new file_queue()
92
-
93
- qRequire.init().process({
94
- appender: "json_name",
95
- exclude_logMsg: ["debug", "silly", "info"], /* default [] */
96
- process_objects: [file_object],
97
- exclude_names: ["all", "status", "version"],
98
- data_to_process_array: file_data
99
- }).then((success) => {
100
- qRequire.logMsg({ msg: `test success: json name non matching objects processed with no errors`.success.italic.bold, type: "success" })
101
- }, (error) => {
102
- if (typeof error == "string") {
103
- qRequire.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
104
- } else {
105
- let add_s = (error.error_count > 1) ? 's' : ''
106
- qRequire.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
107
- }
108
- })
109
-
@@ -1,110 +0,0 @@
1
- var file_queue = require("../app.js"),
2
- fs = require('fs'),
3
- validPath = require('valid-path')
4
-
5
- var file_data = [
6
- { props: { id: 100, name: "all", status: "new", absolute_path: __filename, check: true } },
7
- { props: { id: 101, name: "func_all", status: "done", absolute_path: __filename, check: true } },
8
- { props: { id: 102, name: "top_one", status: "new", absolute_path: __filename, check: true } },
9
- { props: { id: 103, name: "bottom_one", status: "new", absolute_path: __filename, check: true } },
10
- { props: { id: 104, name: "sync_all", status: "done", absolute_path: __filename, check: true } },
11
- { props: { id: 105, name: "status", status: "delete", absolute_path: __filename, check: true } },
12
- { props: { id: 106, name: "name", status: "test", absolute_path: __filename, check: true } },
13
- { props: { id: 107, name: "version", status: "new", absolute_path: __filename, check: true } }
14
- ]
15
-
16
- var file_object = class file_obj {
17
- constructor(props) {
18
- let t = this, fname = "file_obj.constructor"
19
- try {
20
- t.id = props.id
21
- t.log = props.log
22
- t.name = props.name
23
- t.status = props.status
24
- t.path = props.relative_path
25
- t.absolute_path = props.absolute_path
26
- t.errors = false
27
- t.error_msg = 'none'
28
-
29
- // if (t.id == 104) {
30
- // t.errors = true
31
- // t.error_msg = `some sort of error here`
32
- // }
33
- t.base_queue_process_function = t.a_cool_function
34
-
35
- t.do_checks = t.do_checks.bind(t)
36
- t.a_cool_function = t.a_cool_function.bind(t)
37
- t.base_queue_process_function = t.base_queue_process_function.bind(t)
38
-
39
- if (props.check) {
40
- t.do_checks()
41
- }
42
- } catch (e) {
43
- e.message = `${fname} error: ${e.message}`
44
- throw e
45
- }
46
-
47
- return t
48
- }
49
-
50
- do_checks() {
51
- let t = this, path_to_check,
52
- last_item = t.absolute_path.split("\\").pop(),
53
- check_file = t.absolute_path.split(last_item)[0], check_path = t.path.split('/')
54
-
55
- check_file = check_file.replace(/\\/g, "/");
56
- path_to_check = validPath(t.path);
57
-
58
- if (!path_to_check.valid) {
59
- t.errors = true
60
- t.error_msg = `id = ${t.id} name(${t.name}) Error in ${path_to_check.data.input}: ${path_to_check.error})`
61
- }
62
-
63
- check_path.map((dat, i) => {
64
- if (/^[a-zA-Z._]+$/.test(dat)) {
65
- if (dat != '.')
66
- check_file += dat + '/'
67
- }
68
- })
69
- check_file = check_file.slice(0, -1)
70
- try {
71
- if (!fs.existsSync(check_file)) {
72
- t.errors = true
73
- t.error_msg = `id = ${t.id} name(${t.name}) file (${check_file} does not exist)`
74
- }
75
- } catch (e) {
76
- e.message = "file_obj do_checks error: " + e.message
77
- throw (e)
78
- }
79
- }
80
-
81
- a_cool_function(callback) {
82
- let t = this
83
- t.log({ msg: `processing object id ${t.id} name(${t.name}) status(${t.status}). Do a bunch of stuff here.`.silly, type: "silly" })
84
- if (t.errors)
85
- callback({ error: { msg: t.error_msg } })
86
- else
87
- callback({ success: { msg: `id = ${t.id} name(${t.name}) status(${t.status})`}})
88
- }
89
- }
90
-
91
- var qRequire = new file_queue()
92
-
93
- qRequire.init().process({
94
- appender: "json_status",
95
- exclude_logMsg: ["debug", "silly", "info"], /* default [] */
96
- process_objects: [file_object],
97
- include_names: ["all", "status"],
98
- data_to_process_array: file_data
99
- }).then((success) => {
100
- qRequire.logMsg({ msg: `test success: json status matching objects processed with no errors`.success.italic.bold, type: "success" })
101
- }, (error) => {
102
- if (typeof error == "string") {
103
- qRequire.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
104
-
105
- } else {
106
- let add_s = (error.error_count > 1) ? 's' : ''
107
- qRequire.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
108
- }
109
- })
110
-
@@ -1,110 +0,0 @@
1
- var file_queue = require("../app.js"),
2
- fs = require('fs'),
3
- validPath = require('valid-path')
4
-
5
- var file_data = [
6
- { props: { id: 100, name: "all", status: "new", absolute_path: __filename, check: true } },
7
- { props: { id: 101, name: "func_all", status: "done", absolute_path: __filename, check: true } },
8
- { props: { id: 102, name: "top_one", status: "new", absolute_path: __filename, check: true } },
9
- { props: { id: 103, name: "bottom_one", status: "new", absolute_path: __filename, check: true } },
10
- { props: { id: 104, name: "sync_all", status: "done", absolute_path: __filename, check: true } },
11
- { props: { id: 105, name: "status", status: "delete", absolute_path: __filename, check: true } },
12
- { props: { id: 106, name: "name", status: "test", absolute_path: __filename, check: true } },
13
- { props: { id: 107, name: "version", status: "new", absolute_path: __filename, check: true } }
14
- ]
15
-
16
- var file_object = class file_obj {
17
- constructor(props) {
18
- let t = this, fname = "file_obj.constructor"
19
- try {
20
- t.id = props.id
21
- t.log = props.log
22
- t.name = props.name
23
- t.status = props.status
24
- t.path = props.relative_path
25
- t.absolute_path = props.absolute_path
26
- t.errors = false
27
- t.error_msg = 'none'
28
-
29
- // if (t.id == 104) {
30
- // t.errors = true
31
- // t.error_msg = `some sort of error here`
32
- // }
33
- t.base_queue_process_function = t.a_cool_function
34
-
35
- t.do_checks = t.do_checks.bind(t)
36
- t.a_cool_function = t.a_cool_function.bind(t)
37
- t.base_queue_process_function = t.base_queue_process_function.bind(t)
38
-
39
- if (props.check) {
40
- t.do_checks()
41
- }
42
- } catch (e) {
43
- e.message = `${fname} error: ${e.message}`
44
- throw e
45
- }
46
-
47
- return t
48
- }
49
-
50
- do_checks() {
51
- let t = this, path_to_check,
52
- last_item = t.absolute_path.split("\\").pop(),
53
- check_file = t.absolute_path.split(last_item)[0], check_path = t.path.split('/')
54
-
55
- check_file = check_file.replace(/\\/g, "/");
56
- path_to_check = validPath(t.path);
57
-
58
- if (!path_to_check.valid) {
59
- t.errors = true
60
- t.error_msg = `id = ${t.id} name(${t.name}) Error in ${path_to_check.data.input}: ${path_to_check.error})`
61
- }
62
-
63
- check_path.map((dat, i) => {
64
- if (/^[a-zA-Z._]+$/.test(dat)) {
65
- if (dat != '.')
66
- check_file += dat + '/'
67
- }
68
- })
69
- check_file = check_file.slice(0, -1)
70
- try {
71
- if (!fs.existsSync(check_file)) {
72
- t.errors = true
73
- t.error_msg = `id = ${t.id} name(${t.name}) file (${check_file} does not exist)`
74
- }
75
- } catch (e) {
76
- e.message = "file_obj do_checks error: " + e.message
77
- throw (e)
78
- }
79
- }
80
-
81
- a_cool_function(callback) {
82
- let t = this
83
- t.log({ msg: `processing object id ${t.id} name(${t.name}) status(${t.status}). Do a bunch of stuff here.`.silly, type: "silly" })
84
- if (t.errors)
85
- callback({ error: { msg: t.error_msg } })
86
- else
87
- callback({ success: { msg: `id = ${t.id} name(${t.name}) status(${t.status})`}})
88
- }
89
- }
90
-
91
- var qRequire = new file_queue()
92
-
93
- qRequire.init().process({
94
- appender: "json_status",
95
- exclude_logMsg: ["debug", "silly", "info"], /* default [] */
96
- process_objects: [file_object],
97
- exclude_names: ["all", "status"],
98
- data_to_process_array: file_data
99
- }).then((success) => {
100
- qRequire.logMsg({ msg: `test success: json status non matching objects processed with no errors`.success.italic.bold, type: "success" })
101
- }, (error) => {
102
- if (typeof error == "string") {
103
- qRequire.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
104
-
105
- } else {
106
- let add_s = (error.error_count > 1) ? 's' : ''
107
- qRequire.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
108
- }
109
- })
110
-
@@ -1,108 +0,0 @@
1
- var file_queue = require("../app.js"),
2
- fs = require('fs'),
3
- validPath = require('valid-path')
4
-
5
- var file_data = [
6
- { props: { id: 100, name: "all", absolute_path: __filename, check: true } },
7
- { props: { id: 101, name: "func_all", absolute_path: __filename, check: true } },
8
- { props: { id: 102, name: "top_one", absolute_path: __filename, check: true } },
9
- { props: { id: 103, name: "bottom_one", absolute_path: __filename, check: true } },
10
- { props: { id: 104, name: "sync_all", absolute_path: __filename, check: true } },
11
- { props: { id: 105, name: "status", absolute_path: __filename, check: true } },
12
- { props: { id: 106, name: "name", absolute_path: __filename, check: true } },
13
- { props: { id: 107, name: "version", absolute_path: __filename, check: true } }
14
- ]
15
-
16
- var file_object = class file_obj {
17
- constructor(props) {
18
- let t = this, fname = "file_obj.constructor"
19
- try {
20
- t.id = props.id
21
- t.log = props.log
22
- t.name = props.name
23
- t.path = props.relative_path
24
- t.absolute_path = props.absolute_path
25
- t.status = 'init'
26
- t.errors = false
27
- t.error_msg = 'none'
28
-
29
- // if (t.id == 104) {
30
- // t.errors = true
31
- // t.error_msg = `some sort of error here`
32
- // }
33
- // }
34
-
35
- t.process = t.process.bind(t)
36
- t.do_checks = t.do_checks.bind(t)
37
-
38
- if (props.check) {
39
- t.do_checks()
40
- }
41
- } catch (e) {
42
- e.message = `${fname} error: ${e.message}`
43
- throw e
44
- }
45
-
46
- return t
47
- }
48
-
49
- do_checks() {
50
- let t = this, path_to_check,
51
- last_item = t.absolute_path.split("\\").pop(),
52
- check_file = t.absolute_path.split(last_item)[0], check_path = t.path.split('/')
53
-
54
- check_file = check_file.replace(/\\/g, "/");
55
- path_to_check = validPath(t.path);
56
-
57
- if (!path_to_check.valid) {
58
- t.errors = true
59
- t.error_msg = `id = ${t.id} name(${t.name}) Error in ${path_to_check.data.input}: ${path_to_check.error})`
60
- }
61
-
62
- check_path.map((dat, i) => {
63
- if (/^[a-zA-Z._]+$/.test(dat)) {
64
- if (dat != '.')
65
- check_file += dat + '/'
66
- }
67
- })
68
- check_file = check_file.slice(0, -1)
69
- try {
70
- if (!fs.existsSync(check_file)) {
71
- t.errors = true
72
- t.error_msg = `id = ${t.id} name(${t.name}) file (${check_file} does not exist)`
73
- }
74
- } catch (e) {
75
- e.message = "file_obj do_checks error: " + e.message
76
- throw (e)
77
- }
78
- }
79
-
80
- process(callback) {
81
- let t = this
82
- t.log({ msg: `processing object id ${t.id} name: ${t.name}. Do a bunch of stuff here.`.silly, type: "silly" })
83
- if (t.errors)
84
- callback({ error: { msg: t.error_msg } })
85
- else
86
- callback({ success: { msg: `id: ${t.id} name: ${t.name}` } })
87
- }
88
- }
89
-
90
- var qRequire = new file_queue()
91
-
92
- qRequire.init().process({
93
- appender: "json_top_one",
94
- exclude_logMsg: ["debug", "silly", "info"], /* default [] */
95
- process_objects: [file_object],
96
- data_to_process_array: file_data
97
- }).then((success) => {
98
- qRequire.logMsg({ msg: `test success: json_top_one file objects processed with no errors`.success.italic.bold, type: "success" })
99
- }, (error) => {
100
- if (typeof error == "string") {
101
- qRequire.logMsg({msg: `error: ${error}`.error.italic.bold, type: "error"})
102
-
103
- } else {
104
- let add_s = (error.error_count > 1) ? 's' : ''
105
- qRequire.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
106
- }
107
- })
108
-
@@ -1,110 +0,0 @@
1
- var file_queue = require("../app.js"),
2
- fs = require('fs'),
3
- validPath = require('valid-path')
4
-
5
- var file_data = [
6
- { props: { id: 100, name: "all", version: "1.00", absolute_path: __filename, check: true } },
7
- { props: { id: 101, name: "func_all", version: "2.00", absolute_path: __filename, check: true } },
8
- { props: { id: 102, name: "top_one", version: "1.00", absolute_path: __filename, check: true } },
9
- { props: { id: 103, name: "bottom_one", version: "3.00", absolute_path: __filename, check: true } },
10
- { props: { id: 104, name: "sync_all", version: "4.00", absolute_path: __filename, check: true } },
11
- { props: { id: 105, name: "status", version: "5.00", absolute_path: __filename, check: true } },
12
- { props: { id: 106, name: "name", version: "2.00", absolute_path: __filename, check: true } },
13
- { props: { id: 107, name: "version", version: "3.00", absolute_path: __filename, check: true } }
14
- ]
15
-
16
- var file_object = class file_obj {
17
- constructor(props) {
18
- let t = this, fname = "file_obj.constructor"
19
- try {
20
- t.id = props.id
21
- t.log = props.log
22
- t.name = props.name
23
- t.version = props.version
24
- t.path = props.relative_path
25
- t.absolute_path = props.absolute_path
26
- t.errors = false
27
- t.error_msg = 'none'
28
-
29
- // if (t.id == 104) {
30
- // t.errors = true
31
- // t.error_msg = `some sort of error here`
32
- // }
33
- t.base_queue_process_function = t.a_cool_function
34
-
35
- t.do_checks = t.do_checks.bind(t)
36
- t.a_cool_function = t.a_cool_function.bind(t)
37
- t.base_queue_process_function = t.base_queue_process_function.bind(t)
38
-
39
- if (props.check) {
40
- t.do_checks()
41
- }
42
- } catch (e) {
43
- e.message = `${fname} error: ${e.message}`
44
- throw e
45
- }
46
-
47
- return t
48
- }
49
-
50
- do_checks() {
51
- let t = this, path_to_check,
52
- last_item = t.absolute_path.split("\\").pop(),
53
- check_file = t.absolute_path.split(last_item)[0], check_path = t.path.split('/')
54
-
55
- check_file = check_file.replace(/\\/g, "/");
56
- path_to_check = validPath(t.path);
57
-
58
- if (!path_to_check.valid) {
59
- t.errors = true
60
- t.error_msg = `id = ${t.id} name(${t.name}) Error in ${path_to_check.data.input}: ${path_to_check.error})`
61
- }
62
-
63
- check_path.map((dat, i) => {
64
- if (/^[a-zA-Z._]+$/.test(dat)) {
65
- if (dat != '.')
66
- check_file += dat + '/'
67
- }
68
- })
69
- check_file = check_file.slice(0, -1)
70
- try {
71
- if (!fs.existsSync(check_file)) {
72
- t.errors = true
73
- t.error_msg = `id = ${t.id} name(${t.name}) file (${check_file} does not exist)`
74
- }
75
- } catch (e) {
76
- e.message = "file_obj do_checks error: " + e.message
77
- throw (e)
78
- }
79
- }
80
-
81
- a_cool_function(callback) {
82
- let t = this
83
- t.log({ msg: `processing object id ${t.id} name(${t.name}) version(${t.version}). Do a bunch of stuff here.`.silly, type: "silly" })
84
- if (t.errors)
85
- callback({ error: { msg: t.error_msg } })
86
- else
87
- callback({ success: { msg: `id = ${t.id} name(${t.name}) version(${t.version})`}})
88
- }
89
- }
90
-
91
- var qRequire = new file_queue()
92
-
93
- qRequire.init().process({
94
- appender: "json_version",
95
- exclude_logMsg: ["debug", "silly", "info"], /* default [] */
96
- process_objects: [file_object],
97
- include_version: ["2.00", "4.00"],
98
- data_to_process_array: file_data
99
- }).then((success) => {
100
- qRequire.logMsg({ msg: `test success: json_version objects processed with no errors`.success.italic.bold, type: "success" })
101
- }, (error) => {
102
- if (typeof error == "string") {
103
- qRequire.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
104
-
105
- } else {
106
- let add_s = (error.error_count > 1) ? 's' : ''
107
- qRequire.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
108
- }
109
- })
110
-