@makano/rew 1.2.65 → 1.2.66
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/lib/rew/const/usage.js
CHANGED
|
@@ -12,4 +12,18 @@ module.exports.USING_DEFAULT = {
|
|
|
12
12
|
DECORATORS: {
|
|
13
13
|
use: (options) => options.decorators = true
|
|
14
14
|
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports.Usage = class Usage {
|
|
18
|
+
name = "null";
|
|
19
|
+
trigger = () => {}
|
|
20
|
+
|
|
21
|
+
constructor(name, trigger){
|
|
22
|
+
this.name = name;
|
|
23
|
+
this.trigger = trigger;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
create(name, trigger){
|
|
27
|
+
return new Usage(name, trigger);
|
|
28
|
+
}
|
|
15
29
|
}
|
|
@@ -7,7 +7,7 @@ const fsLib = require("../functions/fs");
|
|
|
7
7
|
const pathLib = require("../functions/path");
|
|
8
8
|
const execLib = require("../functions/exec");
|
|
9
9
|
const { findAppInfo } = require("../misc/findAppInfo");
|
|
10
|
-
const { USING_DEFAULT } = require("../const/usage");
|
|
10
|
+
const { USING_DEFAULT, Usage } = require("../const/usage");
|
|
11
11
|
|
|
12
12
|
let mainFile = "";
|
|
13
13
|
const isMainFile = (filepath) => filepath == mainFile;
|
|
@@ -45,6 +45,7 @@ module.exports.prepareContext = function (
|
|
|
45
45
|
...pathLib(filepath),
|
|
46
46
|
...execLib(filepath),
|
|
47
47
|
...custom_context,
|
|
48
|
+
Usage
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
if (!context.process)
|
|
@@ -98,6 +99,8 @@ module.exports.prepareContext = function (
|
|
|
98
99
|
if(USING_DEFAULT[name].param) {
|
|
99
100
|
context.__using__[name] = USING_DEFAULT[name].param(...params);
|
|
100
101
|
}
|
|
102
|
+
} else if(name instanceof Usage) {
|
|
103
|
+
context.__using__[name.name] = name.trigger(...params) || true;
|
|
101
104
|
} else {
|
|
102
105
|
context.__using__[name] = params.length ? params.length > 1 ? [...params] : params : true;
|
|
103
106
|
}
|