@opencode-ai/util 0.0.0-dev-18767 → 0.0.0-dev-18774

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/fs-util.js CHANGED
@@ -183,7 +183,7 @@ export var FSUtil;
183
183
  return normalizePath(realpathSync(resolved));
184
184
  }
185
185
  catch (e) {
186
- if (e?.code === "ENOENT")
186
+ if (e?.code === "ENOENT" || e?.code === "ENOTDIR")
187
187
  return normalizePath(resolved);
188
188
  throw e;
189
189
  }
package/dist/path.js CHANGED
@@ -2,8 +2,8 @@ export function getFilename(path) {
2
2
  if (!path)
3
3
  return "";
4
4
  const trimmed = path.replace(/[/\\]+$/, "");
5
- const parts = trimmed.split(/[/\\]/);
6
- return parts[parts.length - 1] ?? "";
5
+ const index = Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\"));
6
+ return trimmed.slice(index + 1);
7
7
  }
8
8
  export function getDirectory(path) {
9
9
  if (!path)
package/dist/path.test.js CHANGED
@@ -15,6 +15,20 @@ describe("client paths", () => {
15
15
  expect(getFilename(undefined)).toBe("");
16
16
  expect(getDirectory("")).toBe("");
17
17
  });
18
+ test.each([
19
+ ["/repo/src/index.ts///", "index.ts"],
20
+ ["C:\\repo\\src\\index.ts", "index.ts"],
21
+ ["C:\\repo/src\\file", "file"],
22
+ ["C:/repo\\src/file/\\", "file"],
23
+ ["/", ""],
24
+ ["\\", ""],
25
+ ["/\\/\\", ""],
26
+ ["C:\\", "C:"],
27
+ ["file", "file"],
28
+ ["", ""],
29
+ ])("reads the filename from %j", (path, filename) => {
30
+ expect(getFilename(path)).toBe(filename);
31
+ });
18
32
  test("keeps filename truncation stable", () => {
19
33
  expect(getFilenameTruncated("/repo/long-component-name.tsx", 16)).toBe("long-compon….tsx");
20
34
  expect(truncateMiddle("abcdefghijklmnop", 9)).toBe("abcd…mnop");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode-ai/util",
4
- "version": "0.0.0-dev-18767",
4
+ "version": "0.0.0-dev-18774",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {