file-obj-queue 2.0.5 → 3.0.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.
- package/.github/workflows/{github-actions-demo.yml → github-actions.yml} +1 -1
- package/.github/workflows/node.js.yml +1 -0
- package/LICENSE +1 -1
- package/README.md +132 -7
- package/app.js +155 -40
- package/lib/appenders/all.js +17 -0
- package/lib/appenders/base.js +189 -0
- package/lib/appenders/bottom_one.js +17 -0
- package/lib/appenders/func_all.js +17 -0
- package/lib/appenders/name.js +17 -0
- package/lib/appenders/status.js +17 -0
- package/lib/appenders/sync.js +17 -0
- package/lib/appenders/sync_all.js +17 -0
- package/lib/appenders/top_one.js +17 -0
- package/lib/appenders/version.js +17 -0
- package/package.json +24 -3
- package/test/app.js +5 -1
- package/test/package.js +25 -3
- package/tests/all.js +85 -0
- package/tests/appenders/all.js +1 -1
- package/tests/appenders/base.js +1 -1
- package/tests/appenders/bottom_one.js +1 -1
- package/tests/appenders/func_all.js +1 -1
- package/tests/appenders/sync.js +1 -1
- package/tests/appenders/sync_all.js +1 -1
- package/tests/appenders/top_one.js +1 -1
- package/tests/appenders/version.js +1 -1
- package/tests/bottom_one.js +86 -0
- package/tests/files.js +50 -32
- package/tests/func_all.js +94 -0
- package/tests/json_all.js +107 -0
- package/tests/json_bottom_one.js +108 -0
- package/tests/json_func_all.js +109 -0
- package/tests/json_name_matching.js +109 -0
- package/tests/json_name_non_matching.js +109 -0
- package/tests/json_status_matching.js +110 -0
- package/tests/json_status_non_matching.js +110 -0
- package/tests/json_top_one.js +108 -0
- package/tests/json_version_matching.js +110 -0
- package/tests/json_version_non_matching.js +110 -0
- package/tests/name_matching.js +90 -0
- package/tests/name_non_matching.js +90 -0
- package/tests/status_matching.js +90 -0
- package/tests/status_non_matching.js +90 -0
- package/tests/top_one.js +85 -0
- package/tests/version_matching.js +90 -0
- package/tests/version_non_matching.js +90 -0
- package/base_queue/app.js +0 -146
- package/base_queue/appenders/base.js +0 -77
- package/base_queue/appenders/json_all.js +0 -70
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
|
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
|
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
var queue = require("../app.js")
|
|
2
|
+
|
|
3
|
+
var tst1 = class test1 {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
let t = this, fname = "name_matching.test1.constructor"
|
|
6
|
+
t.log = props.log
|
|
7
|
+
t.id = props.id
|
|
8
|
+
t.name = "test 1"
|
|
9
|
+
|
|
10
|
+
t.process = t.process.bind(t)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
process(callback) {
|
|
14
|
+
let t = this, fname = "name_matching.test1.process"
|
|
15
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) name (${t.name}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
16
|
+
callback({ success: { msg: `processing all ${t.name}` } })
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var tst2 = class test2 {
|
|
21
|
+
constructor(props) {
|
|
22
|
+
let t = this, fname = "name_matching.test2.constructor"
|
|
23
|
+
t.log = props.log
|
|
24
|
+
t.id = props.id
|
|
25
|
+
t.name = "test 2"
|
|
26
|
+
|
|
27
|
+
t.process = t.process.bind(t)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
process(callback) {
|
|
31
|
+
let t = this, fname = "name_matching.test2.process"
|
|
32
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) name (${t.name}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
callback({ success: { msg: `processing all ${t.name}` } })
|
|
35
|
+
}, 4000)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var tst3 = class test3 {
|
|
40
|
+
constructor(props) {
|
|
41
|
+
let t = this, fname = "name_matching.test3.constructor"
|
|
42
|
+
t.log = props.log
|
|
43
|
+
t.id = props.id
|
|
44
|
+
t.name = "test 3"
|
|
45
|
+
|
|
46
|
+
t.process = t.process.bind(t)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
process(callback) {
|
|
50
|
+
let t = this, fname = "name_matching.test3.process"
|
|
51
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) name (${t.name}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
52
|
+
// callback({success: { msg: `processing all ${t.name}` }})
|
|
53
|
+
callback({ error: { msg: `there is some problem thrown here on ${t.name}` } })
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var tst4 = class test4 {
|
|
58
|
+
constructor(props) {
|
|
59
|
+
let t = this, fname = "name_matching.test4.constructor"
|
|
60
|
+
t.log = props.log
|
|
61
|
+
t.id = props.id
|
|
62
|
+
t.name = "test 4"
|
|
63
|
+
|
|
64
|
+
t.process = t.process.bind(t)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
process(callback) {
|
|
68
|
+
let t = this, fname = "name_matching.test4.process"
|
|
69
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) name (${t.name}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
70
|
+
callback({ success: { msg: `processing all ${t.name}` } })
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var qObj = new queue()
|
|
75
|
+
|
|
76
|
+
qObj.init().process({
|
|
77
|
+
appender: "name",
|
|
78
|
+
exclude_logMsg: ["debug"], /* example ["debug", "info"] */
|
|
79
|
+
include_names: ["test 2", "test 4"],
|
|
80
|
+
process_objects: [tst1, tst2, tst3, tst4]
|
|
81
|
+
}).then((success) => {
|
|
82
|
+
qObj.logMsg({ msg: `test success: {msg: "name matching objects processed with no errors"}`.success.italic.bold, type: "success" })
|
|
83
|
+
}, (error) => {
|
|
84
|
+
if (typeof error == "string") {
|
|
85
|
+
qObj.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
|
|
86
|
+
} else {
|
|
87
|
+
let add_s = (error.error_count > 1) ? 's' : ''
|
|
88
|
+
qObj.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
|
|
89
|
+
}
|
|
90
|
+
})
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
var queue = require("../app.js")
|
|
2
|
+
|
|
3
|
+
var tst1 = class test1 {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
let t = this, fname = "name_non_matching.test1.constructor"
|
|
6
|
+
t.log = props.log
|
|
7
|
+
t.id = props.id
|
|
8
|
+
t.name = "test 1"
|
|
9
|
+
|
|
10
|
+
t.process = t.process.bind(t)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
process(callback) {
|
|
14
|
+
let t = this, fname = "name_non_matching.test1.process"
|
|
15
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) name (${t.name}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
16
|
+
callback({ success: { msg: `processing all ${t.name}` } })
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var tst2 = class test2 {
|
|
21
|
+
constructor(props) {
|
|
22
|
+
let t = this, fname = "name_non_matching.test2.constructor"
|
|
23
|
+
t.log = props.log
|
|
24
|
+
t.id = props.id
|
|
25
|
+
t.name = "test 2"
|
|
26
|
+
|
|
27
|
+
t.process = t.process.bind(t)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
process(callback) {
|
|
31
|
+
let t = this, fname = "name_non_matching.test2.process"
|
|
32
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) name (${t.name}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
callback({ success: { msg: `processing all ${t.name}` } })
|
|
35
|
+
}, 4000)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var tst3 = class test3 {
|
|
40
|
+
constructor(props) {
|
|
41
|
+
let t = this, fname = "name_non_matching.test3.constructor"
|
|
42
|
+
t.log = props.log
|
|
43
|
+
t.id = props.id
|
|
44
|
+
t.name = "test 3"
|
|
45
|
+
|
|
46
|
+
t.process = t.process.bind(t)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
process(callback) {
|
|
50
|
+
let t = this, fname = "name_non_matching.test3.process"
|
|
51
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) name (${t.name}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
52
|
+
// callback({success: { msg: `processing all ${t.name}` }})
|
|
53
|
+
callback({ error: { msg: `there is some problem thrown here on ${t.name}` } })
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var tst4 = class test4 {
|
|
58
|
+
constructor(props) {
|
|
59
|
+
let t = this, fname = "name_non_matching.test4.constructor"
|
|
60
|
+
t.log = props.log
|
|
61
|
+
t.id = props.id
|
|
62
|
+
t.name = "test 4"
|
|
63
|
+
|
|
64
|
+
t.process = t.process.bind(t)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
process(callback) {
|
|
68
|
+
let t = this, fname = "name_non_matching.test4.process"
|
|
69
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) name (${t.name}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
70
|
+
callback({ success: { msg: `processing all ${t.name}` } })
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var qObj = new queue()
|
|
75
|
+
|
|
76
|
+
qObj.init().process({
|
|
77
|
+
appender: "name",
|
|
78
|
+
exclude_logMsg: ["debug"], /* example ["debug", "info"] */
|
|
79
|
+
exclude_names: ["test 2", "test 4"],
|
|
80
|
+
process_objects: [tst1, tst2, tst3, tst4]
|
|
81
|
+
}).then((success) => {
|
|
82
|
+
qObj.logMsg({ msg: `test success: {msg: "name non matching objects processed with no errors"}`.success.italic.bold, type: "success" })
|
|
83
|
+
}, (error) => {
|
|
84
|
+
if (typeof error == "string") {
|
|
85
|
+
qObj.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
|
|
86
|
+
} else {
|
|
87
|
+
let add_s = (error.error_count > 1) ? 's' : ''
|
|
88
|
+
qObj.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
|
|
89
|
+
}
|
|
90
|
+
})
|