sommark 4.0.1 → 4.0.2

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.
@@ -31,10 +31,15 @@ export async function transpile({ src, format, filename = null, mapperFile = "",
31
31
  }
32
32
 
33
33
  // Custom Mapper (String Path)
34
- if (typeof finalMapper === "string" && finalMapper !== "" && (await isExist(finalMapper))) {
35
- const mapperFileURL = pathToFileURL(path.resolve(process.cwd(), finalMapper)).href;
36
- const loadedMapper = await import(mapperFileURL);
37
- finalMapper = loadedMapper.default;
34
+ if (typeof finalMapper === "string" && finalMapper !== "") {
35
+ const baseDir = finalConfig.resolvedConfigPath ? path.dirname(finalConfig.resolvedConfigPath) : process.cwd();
36
+ const absoluteMapperPath = path.resolve(baseDir, finalMapper);
37
+
38
+ if (await isExist(absoluteMapperPath)) {
39
+ const mapperFileURL = `${pathToFileURL(absoluteMapperPath).href}?t=${Date.now()}`;
40
+ const loadedMapper = await import(mapperFileURL);
41
+ finalMapper = loadedMapper.default;
42
+ }
38
43
  }
39
44
  }
40
45
 
@@ -48,14 +48,25 @@ export async function findAndLoadConfig(targetPath) {
48
48
  }
49
49
  }
50
50
 
51
- // 2. Check the current folder
51
+ // 2. Check the target directory
52
52
  if (!configPath) {
53
53
  const localConfig = path.join(startDir, CONFIG_FILE_NAME);
54
54
  try {
55
55
  await fs.access(localConfig);
56
56
  configPath = localConfig;
57
57
  } catch {
58
- // No local config found
58
+ // No local config found in target dir
59
+ }
60
+ }
61
+
62
+ // 3. Check the current working directory (if different from target dir)
63
+ if (!configPath && startDir !== process.cwd()) {
64
+ const cwdConfig = path.join(process.cwd(), CONFIG_FILE_NAME);
65
+ try {
66
+ await fs.access(cwdConfig);
67
+ configPath = cwdConfig;
68
+ } catch {
69
+ // No config found in CWD
59
70
  }
60
71
  }
61
72
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sommark",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "SomMark is a declarative, extensible markup language for structured content that can be converted to HTML, Markdown, MDX, JSON, XML, and more.",
5
5
  "main": "index.js",
6
6
  "files": [