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 CHANGED
@@ -71,7 +71,9 @@ module.exports = (arg1, arg2, opt) => {
71
71
  if (opt.watch) {
72
72
  let wcer = chokidar.watch(arg1);
73
73
  console.log('watching...')
74
- wcer.on('change', doit);
74
+ wcer.on('change', ()=>{
75
+ doit();
76
+ });
75
77
  } else {
76
78
  doit();
77
79
  }
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
- require('./xml2cbFn.js')(xmlFile, jsFile, options);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cuxml",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "A tool to help use ribbon UI for your WPS Office Client JS add-in project.",
5
5
  "keywords": [
6
6
  "wps office",
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
- // 目前,所有回调都只支持一个参数,多出来的一律 undefined。ctrl 的成员如下👇🏻:
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
  }