cuxml 1.0.5 → 1.0.6
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/cxml_w.js +3 -1
- package/index.js +4 -3
- package/package.json +1 -1
- package/xml2cbFn.js +1 -3
package/cxml_w.js
CHANGED
package/index.js
CHANGED
|
@@ -23,13 +23,14 @@ program.command('callback')
|
|
|
23
23
|
.argument('<jsFile>', '要写入的 JavaScript 文件')
|
|
24
24
|
.option('-w, --write', '写入方式: 覆盖 JS 文件 <jsFile>')
|
|
25
25
|
.option('-a, --append', '写入方式: 追加到 <jsFile> 文件末尾')
|
|
26
|
-
.option('-watch, --watch', '监视 <xmlFile>
|
|
26
|
+
.option('-watch, --watch', '监视 <xmlFile> 文件, 当文件发生变化时自动更新 <jsFile>,写入模式为覆盖')
|
|
27
27
|
.action((xmlFile, jsFile, options) => {
|
|
28
28
|
//console.log(JSON.stringify([options, xmlFile, jsFile]));
|
|
29
29
|
if(options.watch){
|
|
30
30
|
let w = require('chokidar').watch(xmlFile);
|
|
31
|
-
w.on('change', () => {
|
|
32
|
-
|
|
31
|
+
w.on('change', (p,s) => {
|
|
32
|
+
let xmlFile = p;
|
|
33
|
+
require('./xml2cbFn.js')(xmlFile, jsFile, {write: true});
|
|
33
34
|
})
|
|
34
35
|
}else{
|
|
35
36
|
require('./xml2cbFn.js')(xmlFile, jsFile, options);
|
package/package.json
CHANGED
package/xml2cbFn.js
CHANGED
|
@@ -120,9 +120,7 @@ module.exports = (arg1, arg2, flag) => {
|
|
|
120
120
|
* Time: ${new Date()}
|
|
121
121
|
*/
|
|
122
122
|
function ${attrValue}(ctrl){
|
|
123
|
-
|
|
124
|
-
// ctrl={Id:'string', content:{...}, Tag:'string'}
|
|
125
|
-
${cases.length > 1 ? `switch(ctrl.Id){\n${spaceReapts(8)}${cases.join('\n')}\ndefault:\n${spaceReapts(8)}break;\n${cbType=='void'?`${spaceReapts(8)}return true;//动作、事件类回调需要返回 true};`:``}` : `${cases.join('\n')}\n//根据回调属性返回准确的类型`}
|
|
123
|
+
${cases.length > 1 ? `switch(ctrl.Id){\n${spaceReapts(8)}${cases.join('\n ')}\ndefault:\n${spaceReapts(8)}break;\n${cbType=='void'?`${spaceReapts(8)}}\nreturn true;\n}`:``}` : `${cases.join('\n')}\n`}
|
|
126
124
|
}`;
|
|
127
125
|
}
|
|
128
126
|
}
|