@unocss/config 0.31.8 → 0.31.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +12 -19
- package/dist/index.d.ts +2 -3
- package/dist/index.mjs +15 -21
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -10,21 +10,20 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
10
10
|
|
|
11
11
|
const fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
12
12
|
|
|
13
|
-
function
|
|
13
|
+
async function loadConfig(cwd = process.cwd(), configOrPath = cwd, extraConfigSources = []) {
|
|
14
14
|
let inlineConfig = {};
|
|
15
15
|
if (typeof configOrPath !== "string") {
|
|
16
16
|
inlineConfig = configOrPath;
|
|
17
17
|
if (inlineConfig.configFile === false) {
|
|
18
|
-
return
|
|
18
|
+
return {
|
|
19
19
|
config: inlineConfig,
|
|
20
20
|
sources: []
|
|
21
|
-
}
|
|
21
|
+
};
|
|
22
22
|
} else {
|
|
23
23
|
configOrPath = inlineConfig.configFile || process.cwd();
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
const resolved = path.resolve(configOrPath);
|
|
27
|
-
let cwd = resolved;
|
|
28
27
|
let isFile = false;
|
|
29
28
|
if (fs__default.existsSync(resolved) && fs__default.statSync(resolved).isFile()) {
|
|
30
29
|
isFile = true;
|
|
@@ -48,21 +47,15 @@ function createConfigLoader(configOrPath = process.cwd(), extraConfigSources = [
|
|
|
48
47
|
cwd,
|
|
49
48
|
defaults: inlineConfig
|
|
50
49
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
result.sources
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return result;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
function loadConfig(dirOrPath) {
|
|
64
|
-
return createConfigLoader(dirOrPath)();
|
|
50
|
+
const result = await loader.load();
|
|
51
|
+
result.config = result.config || inlineConfig;
|
|
52
|
+
if (result.config.configDeps) {
|
|
53
|
+
result.sources = [
|
|
54
|
+
...result.sources,
|
|
55
|
+
...result.config.configDeps.map((i) => path.resolve(cwd, i))
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
65
59
|
}
|
|
66
60
|
|
|
67
|
-
exports.createConfigLoader = createConfigLoader;
|
|
68
61
|
exports.loadConfig = loadConfig;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { UserConfig } from '@unocss/core';
|
|
|
2
2
|
import { LoadConfigSource, LoadConfigResult } from 'unconfig';
|
|
3
3
|
export { LoadConfigResult, LoadConfigSource } from 'unconfig';
|
|
4
4
|
|
|
5
|
-
declare function
|
|
6
|
-
declare function loadConfig<U extends UserConfig>(dirOrPath: string | U): Promise<LoadConfigResult<U>>;
|
|
5
|
+
declare function loadConfig<U extends UserConfig>(cwd?: string, configOrPath?: string | U, extraConfigSources?: LoadConfigSource[]): Promise<LoadConfigResult<U>>;
|
|
7
6
|
|
|
8
|
-
export {
|
|
7
|
+
export { loadConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import { resolve, dirname } from 'path';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
import { createConfigLoader
|
|
3
|
+
import { createConfigLoader } from 'unconfig';
|
|
4
4
|
|
|
5
|
-
function
|
|
5
|
+
async function loadConfig(cwd = process.cwd(), configOrPath = cwd, extraConfigSources = []) {
|
|
6
6
|
let inlineConfig = {};
|
|
7
7
|
if (typeof configOrPath !== "string") {
|
|
8
8
|
inlineConfig = configOrPath;
|
|
9
9
|
if (inlineConfig.configFile === false) {
|
|
10
|
-
return
|
|
10
|
+
return {
|
|
11
11
|
config: inlineConfig,
|
|
12
12
|
sources: []
|
|
13
|
-
}
|
|
13
|
+
};
|
|
14
14
|
} else {
|
|
15
15
|
configOrPath = inlineConfig.configFile || process.cwd();
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
const resolved = resolve(configOrPath);
|
|
19
|
-
let cwd = resolved;
|
|
20
19
|
let isFile = false;
|
|
21
20
|
if (fs.existsSync(resolved) && fs.statSync(resolved).isFile()) {
|
|
22
21
|
isFile = true;
|
|
23
22
|
cwd = dirname(resolved);
|
|
24
23
|
}
|
|
25
|
-
const loader = createConfigLoader
|
|
24
|
+
const loader = createConfigLoader({
|
|
26
25
|
sources: isFile ? [
|
|
27
26
|
{
|
|
28
27
|
files: resolved,
|
|
@@ -40,20 +39,15 @@ function createConfigLoader(configOrPath = process.cwd(), extraConfigSources = [
|
|
|
40
39
|
cwd,
|
|
41
40
|
defaults: inlineConfig
|
|
42
41
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
result.sources
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return result;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function loadConfig(dirOrPath) {
|
|
56
|
-
return createConfigLoader(dirOrPath)();
|
|
42
|
+
const result = await loader.load();
|
|
43
|
+
result.config = result.config || inlineConfig;
|
|
44
|
+
if (result.config.configDeps) {
|
|
45
|
+
result.sources = [
|
|
46
|
+
...result.sources,
|
|
47
|
+
...result.config.configDeps.map((i) => resolve(cwd, i))
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
57
51
|
}
|
|
58
52
|
|
|
59
|
-
export {
|
|
53
|
+
export { loadConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/config",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.12",
|
|
4
4
|
"description": "Config loader for UnoCSS",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/unocss/unocss/tree/main/packages/config#readme",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"node": ">=14"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@unocss/core": "0.31.
|
|
35
|
+
"@unocss/core": "0.31.12",
|
|
36
36
|
"unconfig": "^0.3.3"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|