Urara-Blog/node_modules/.pnpm-store/v3/files/37/56d690ee3aee8e50e8f908d73dc0ecd39d505c181024965167fc77964c01e4fb032a0f60cdc6251735d262f6de40cdd5fd2d5cb0ee9cb0459413c640dc504c
2022-08-14 01:14:53 +08:00

61 lines
1.5 KiB
Text

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const path = require('path');
const fs = require('fs');
const unconfig = require('unconfig');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
const fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
async function loadConfig(cwd = process.cwd(), configOrPath = cwd, extraConfigSources = []) {
let inlineConfig = {};
if (typeof configOrPath !== "string") {
inlineConfig = configOrPath;
if (inlineConfig.configFile === false) {
return {
config: inlineConfig,
sources: []
};
} else {
configOrPath = inlineConfig.configFile || process.cwd();
}
}
const resolved = path.resolve(configOrPath);
let isFile = false;
if (fs__default.existsSync(resolved) && fs__default.statSync(resolved).isFile()) {
isFile = true;
cwd = path.dirname(resolved);
}
const loader = unconfig.createConfigLoader({
sources: isFile ? [
{
files: resolved,
extensions: []
}
] : [
{
files: [
"unocss.config",
"uno.config"
]
},
...extraConfigSources
],
cwd,
defaults: inlineConfig
});
const result = await loader.load();
result.config = result.config || inlineConfig;
if (result.config.configDeps) {
result.sources = [
...result.sources,
...result.config.configDeps.map((i) => path.resolve(cwd, i))
];
}
return result;
}
exports.loadConfig = loadConfig;