浏览代码

add a new parameter to codegen to specify a target file: e.g., node uiwidgets-cli.js codegen Runtime/rendering box.mixin.njk

/siyaoH-1.17-PlatformMessage
xingweizhu 4 年前
当前提交
0e6a88b9
共有 1 个文件被更改,包括 15 次插入3 次删除
  1. 18
      com.unity.uiwidgets/Scripts/cmds/codegen.js

18
com.unity.uiwidgets/Scripts/cmds/codegen.js


var nunjucks = require('nunjucks');
var chokidar = require('chokidar');
exports.command = 'codegen [dir]';
exports.command = 'codegen [dir] [file]';
exports.desc = "generate mixin code";
exports.builder = function (yargs) {
return yargs.positional('dir', {

}).positional('file', {
describe: 'the target file if specified',
type: 'string',
default: ''
}).option('watch', {
alias: 'w',
describe: 'Watch for file changes',

exports.handler = function (argv) {
var cwd = path.resolve(__dirname, '../..', argv.dir);
var file = ''
if (argv.file != '') {
file = argv.file;
}
var data = {};
var env = nunjucks.configure(cwd, {
trimBlocks: true,

if (err) {
return console.error(chalk.red(err));
}
renderAll(env, cwd, files, data);
if (files.indexOf(file) >=0) {
render(env, cwd, file, data);
}
else {
renderAll(env, cwd, files, data);
}
});
if (argv.watch) {

正在加载...
取消
保存