mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
32 lines
816 B
JavaScript
32 lines
816 B
JavaScript
|
|
#!/usr/bin/env node
|
||
|
|
|
||
|
|
// this is the "compile_owl_templates" command that owl makes available when
|
||
|
|
// installed as a node_module.
|
||
|
|
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
||
|
|
import { dirname } from "path";
|
||
|
|
import { compileTemplates } from "../dist/compile_templates.mjs";
|
||
|
|
import { parseArgs } from "util";
|
||
|
|
|
||
|
|
const { values, positionals } = parseArgs({
|
||
|
|
allowPositionals: true,
|
||
|
|
options: {
|
||
|
|
output: {
|
||
|
|
type: "string",
|
||
|
|
short: "o",
|
||
|
|
default: "templates.js",
|
||
|
|
},
|
||
|
|
},
|
||
|
|
});
|
||
|
|
|
||
|
|
if (positionals.length) {
|
||
|
|
const result = await compileTemplates(positionals);
|
||
|
|
const outputPath = values.output;
|
||
|
|
const dir = dirname(outputPath);
|
||
|
|
if (!existsSync(dir)) {
|
||
|
|
mkdirSync(dir, { recursive: true });
|
||
|
|
}
|
||
|
|
writeFileSync(outputPath, result);
|
||
|
|
} else {
|
||
|
|
console.log("Please provide a path");
|
||
|
|
}
|