@unocss/config 0.31.10 → 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 CHANGED
@@ -10,59 +10,52 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  const fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
12
12
 
13
- function createConfigLoader(_configOrPath, extraConfigSources = []) {
13
+ async function loadConfig(cwd = process.cwd(), configOrPath = cwd, extraConfigSources = []) {
14
14
  let inlineConfig = {};
15
- return async (configOrPath = _configOrPath) => {
16
- if (typeof configOrPath !== "string") {
17
- inlineConfig = configOrPath;
18
- if (inlineConfig.configFile === false) {
19
- return {
20
- config: inlineConfig,
21
- sources: []
22
- };
23
- } else {
24
- configOrPath = inlineConfig.configFile || process.cwd();
25
- }
26
- }
27
- const resolved = path.resolve(configOrPath);
28
- let cwd = resolved;
29
- let isFile = false;
30
- if (fs__default.existsSync(resolved) && fs__default.statSync(resolved).isFile()) {
31
- isFile = true;
32
- cwd = path.dirname(resolved);
33
- }
34
- const loader = unconfig.createConfigLoader({
35
- sources: isFile ? [
36
- {
37
- files: resolved,
38
- extensions: []
39
- }
40
- ] : [
41
- {
42
- files: [
43
- "unocss.config",
44
- "uno.config"
45
- ]
46
- },
47
- ...extraConfigSources
48
- ],
49
- cwd,
50
- defaults: inlineConfig
51
- });
52
- const result = await loader.load();
53
- result.config = result.config || inlineConfig;
54
- if (result.config.configDeps) {
55
- result.sources = [
56
- ...result.sources,
57
- ...result.config.configDeps.map((i) => path.resolve(cwd, i))
58
- ];
15
+ if (typeof configOrPath !== "string") {
16
+ inlineConfig = configOrPath;
17
+ if (inlineConfig.configFile === false) {
18
+ return {
19
+ config: inlineConfig,
20
+ sources: []
21
+ };
22
+ } else {
23
+ configOrPath = inlineConfig.configFile || process.cwd();
59
24
  }
60
- return result;
61
- };
62
- }
63
- function loadConfig(dirOrPath) {
64
- return createConfigLoader(dirOrPath)();
25
+ }
26
+ const resolved = path.resolve(configOrPath);
27
+ let isFile = false;
28
+ if (fs__default.existsSync(resolved) && fs__default.statSync(resolved).isFile()) {
29
+ isFile = true;
30
+ cwd = path.dirname(resolved);
31
+ }
32
+ const loader = unconfig.createConfigLoader({
33
+ sources: isFile ? [
34
+ {
35
+ files: resolved,
36
+ extensions: []
37
+ }
38
+ ] : [
39
+ {
40
+ files: [
41
+ "unocss.config",
42
+ "uno.config"
43
+ ]
44
+ },
45
+ ...extraConfigSources
46
+ ],
47
+ cwd,
48
+ defaults: inlineConfig
49
+ });
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 createConfigLoader<U extends UserConfig>(_configOrPath: string | U, extraConfigSources?: LoadConfigSource[]): (configOrPath?: string | U) => Promise<LoadConfigResult<U>>;
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 { createConfigLoader, loadConfig };
7
+ export { loadConfig };
package/dist/index.mjs CHANGED
@@ -1,59 +1,53 @@
1
1
  import { resolve, dirname } from 'path';
2
2
  import fs from 'fs';
3
- import { createConfigLoader as createConfigLoader$1 } from 'unconfig';
3
+ import { createConfigLoader } from 'unconfig';
4
4
 
5
- function createConfigLoader(_configOrPath, extraConfigSources = []) {
5
+ async function loadConfig(cwd = process.cwd(), configOrPath = cwd, extraConfigSources = []) {
6
6
  let inlineConfig = {};
7
- return async (configOrPath = _configOrPath) => {
8
- if (typeof configOrPath !== "string") {
9
- inlineConfig = configOrPath;
10
- if (inlineConfig.configFile === false) {
11
- return {
12
- config: inlineConfig,
13
- sources: []
14
- };
15
- } else {
16
- configOrPath = inlineConfig.configFile || process.cwd();
17
- }
18
- }
19
- const resolved = resolve(configOrPath);
20
- let cwd = resolved;
21
- let isFile = false;
22
- if (fs.existsSync(resolved) && fs.statSync(resolved).isFile()) {
23
- isFile = true;
24
- cwd = dirname(resolved);
25
- }
26
- const loader = createConfigLoader$1({
27
- sources: isFile ? [
28
- {
29
- files: resolved,
30
- extensions: []
31
- }
32
- ] : [
33
- {
34
- files: [
35
- "unocss.config",
36
- "uno.config"
37
- ]
38
- },
39
- ...extraConfigSources
40
- ],
41
- cwd,
42
- defaults: inlineConfig
43
- });
44
- const result = await loader.load();
45
- result.config = result.config || inlineConfig;
46
- if (result.config.configDeps) {
47
- result.sources = [
48
- ...result.sources,
49
- ...result.config.configDeps.map((i) => resolve(cwd, i))
50
- ];
7
+ if (typeof configOrPath !== "string") {
8
+ inlineConfig = configOrPath;
9
+ if (inlineConfig.configFile === false) {
10
+ return {
11
+ config: inlineConfig,
12
+ sources: []
13
+ };
14
+ } else {
15
+ configOrPath = inlineConfig.configFile || process.cwd();
51
16
  }
52
- return result;
53
- };
54
- }
55
- function loadConfig(dirOrPath) {
56
- return createConfigLoader(dirOrPath)();
17
+ }
18
+ const resolved = resolve(configOrPath);
19
+ let isFile = false;
20
+ if (fs.existsSync(resolved) && fs.statSync(resolved).isFile()) {
21
+ isFile = true;
22
+ cwd = dirname(resolved);
23
+ }
24
+ const loader = createConfigLoader({
25
+ sources: isFile ? [
26
+ {
27
+ files: resolved,
28
+ extensions: []
29
+ }
30
+ ] : [
31
+ {
32
+ files: [
33
+ "unocss.config",
34
+ "uno.config"
35
+ ]
36
+ },
37
+ ...extraConfigSources
38
+ ],
39
+ cwd,
40
+ defaults: inlineConfig
41
+ });
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 { createConfigLoader, loadConfig };
53
+ export { loadConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/config",
3
- "version": "0.31.10",
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.10",
35
+ "@unocss/core": "0.31.12",
36
36
  "unconfig": "^0.3.3"
37
37
  },
38
38
  "scripts": {