@alicloud/console-toolkit-plugin-react
Version:
console toolkit plugin for base react app
34 lines (33 loc) • 1.01 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var fs_1 = require("fs");
var path_1 = require("path");
function default_1(theme, opts) {
if (opts === void 0) { opts = {}; }
var _a = opts.cwd, cwd = _a === void 0 ? process.cwd() : _a;
if (!theme) {
return {};
}
if (typeof theme === 'string') {
var themePath = (0, path_1.isAbsolute)(theme) ? theme : (0, path_1.resolve)(cwd, theme);
if ((0, fs_1.existsSync)(themePath)) {
try {
var themeConfig = require(themePath); // eslint-disable-line
if (typeof themeConfig === 'function') {
return themeConfig();
}
else {
return themeConfig;
}
}
catch (e) {
return {};
}
}
else {
throw new Error("theme file don't exists");
}
}
return theme;
}
exports.default = default_1;
;