multi-tasks 1.0.1 → 1.0.2
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.
|
@@ -22,6 +22,7 @@ let mvTask = (oldPath, newPath, oldfname, callback)=>{
|
|
|
22
22
|
//console.log('>>>', oldPath, newPath, oldfname)
|
|
23
23
|
let oldfPath = pathutil.resolve(oldPath, oldfname);
|
|
24
24
|
let newfPath = pathutil.resolve(newPath, oldfname);
|
|
25
|
+
//if(fs.existsSync(newfPath)) fs.rmSync(newfPath, {force: true});
|
|
25
26
|
fs.rename(oldfPath, newfPath, (err) => {
|
|
26
27
|
if (err) throw err;
|
|
27
28
|
callback(newfPath);
|
|
@@ -29,33 +30,26 @@ let mvTask = (oldPath, newPath, oldfname, callback)=>{
|
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
let _do = (mainTaskInfo, actions, callback)=>{
|
|
32
|
-
let{
|
|
33
|
+
let{dynamicTasksFolderNew, dynamicTasksFolderSucc, dynamicTasksFolderFail} = mainTaskInfo.defination;
|
|
33
34
|
|
|
34
|
-
let tasks = loadTaskFile(
|
|
35
|
+
let tasks = loadTaskFile(dynamicTasksFolderNew);
|
|
35
36
|
|
|
36
37
|
if(tasks.length === 0) return callback({data:'hahaha'+Math.random()});
|
|
37
38
|
let task = tasks[0];
|
|
38
39
|
let fpath = task.fpath;
|
|
39
40
|
|
|
40
|
-
mvTask(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
console.log('processing', fpath);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
{
|
|
49
|
-
|
|
50
|
-
//processing....
|
|
41
|
+
mvTask(dynamicTasksFolderNew, dynamicTasksFolderSucc, task.file);
|
|
42
|
+
|
|
43
|
+
{
|
|
44
|
+
//processing...
|
|
45
|
+
console.log('processing...', fpath);
|
|
51
46
|
}
|
|
52
47
|
|
|
53
48
|
_do(mainTaskInfo, actions, callback);
|
|
54
49
|
};
|
|
55
50
|
|
|
56
51
|
|
|
57
|
-
class TestConsumer extends SuperConsumer {
|
|
58
|
-
|
|
52
|
+
class TestConsumer extends SuperConsumer {
|
|
59
53
|
// constructor
|
|
60
54
|
constructor(taskname, parentfolder) {
|
|
61
55
|
super(taskname, parentfolder)
|
|
@@ -19,13 +19,16 @@ let NUMBER_OF_WORKS = 6;//LOCK NUMBER OF WORKERS
|
|
|
19
19
|
|
|
20
20
|
let taskConfig = {
|
|
21
21
|
NUMBER_OF_WORKS,
|
|
22
|
-
|
|
22
|
+
dynamicTasksFolderNew: pathutil.resolve(multi_task_parent_folder, `./dynamicTasks-NEW`),
|
|
23
23
|
dynamicTasksFolderSucc: pathutil.resolve(multi_task_parent_folder, `./dynamicTasks-SUCC`),
|
|
24
24
|
dynamicTasksFolderFail: pathutil.resolve(multi_task_parent_folder, `./dynamicTasks-FAIL`),
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
if(!fs.existsSync(taskConfig.dynamicTasksFolderNew)) throw "Must create folder, DO NOT create by code!";
|
|
28
|
+
if(!fs.existsSync(taskConfig.dynamicTasksFolderSucc)) throw "Must create folder, DO NOT create by code!";
|
|
29
|
+
if(!fs.existsSync(taskConfig.dynamicTasksFolderFail)) throw "Must create folder, DO NOT create by code!";
|
|
30
|
+
|
|
27
31
|
|
|
28
|
-
console.log(`xxxxxxxxxxxxxxxx----`)
|
|
29
32
|
producer.setTaskTrunkInfo(taskConfig);
|
|
30
33
|
consumer.setTaskTrunkInfo(taskConfig)
|
|
31
34
|
master.run(producer, consumer, {
|