[REF] config: move mode from owl.__info__ to owl.config

and move it to its own file.
This commit is contained in:
Aaron Bohy
2019-10-14 13:10:33 +02:00
committed by Géry Debongnie
parent 9e37b968e8
commit 9f93da4765
2 changed files with 33 additions and 17 deletions
+31
View File
@@ -0,0 +1,31 @@
import { QWeb } from "./qweb/index";
/**
* This file creates and exports the OWL 'config' object, with keys:
* - 'mode': 'prod' or 'dev',
*/
interface Config {
mode: string;
}
const _config:Partial<Config> = {};
Object.defineProperty(_config, "mode", {
get() {
return QWeb.dev ? "dev" : "prod";
},
set(mode: string) {
QWeb.dev = mode === "dev";
if (QWeb.dev) {
const url = `https://github.com/odoo/owl/blob/master/doc/tooling.md#development-mode`;
console.warn(
`Owl is running in 'dev' mode. This is not suitable for production use. See ${url} for more information.`
);
} else {
console.log(`Owl is now running in 'prod' mode.`);
}
},
});
export const config:Config = _config as Config;