@vibe-validate/utils 0.17.6 → 0.18.0-rc.1

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.
@@ -69,17 +69,22 @@ export declare function mkdirSyncReal(path: string, options?: Parameters<typeof
69
69
  * Normalize any path (resolve short names on Windows)
70
70
  *
71
71
  * Utility to normalize paths without creating directories.
72
- * Useful when you have an existing path that might contain short names.
72
+ * Accepts multiple path segments like path.resolve() for convenience.
73
73
  *
74
- * @param path - Path to normalize
75
- * @returns Real (normalized) path, or original if normalization fails
74
+ * @param paths - Path segments to join and normalize
75
+ * @returns Real (normalized) path, or resolved path if normalization fails
76
76
  *
77
77
  * @example
78
78
  * ```typescript
79
+ * // Single path
79
80
  * const shortPath = 'C:\\PROGRA~1\\nodejs';
80
81
  * const longPath = normalizePath(shortPath);
81
82
  * // Result: 'C:\\Program Files\\nodejs'
83
+ *
84
+ * // Multiple segments (like path.resolve)
85
+ * const cliPath = normalizePath(__dirname, '../../dist/bin.js');
86
+ * // Resolves to absolute path AND normalizes short names
82
87
  * ```
83
88
  */
84
- export declare function normalizePath(path: string): string;
89
+ export declare function normalizePath(...paths: string[]): string;
85
90
  //# sourceMappingURL=path-helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"path-helpers.d.ts","sourceRoot":"","sources":["../src/path-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAgB,MAAM,SAAS,CAAC;AAGlD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAUzC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,GACxC,MAAM,CAYR;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOlD"}
1
+ {"version":3,"file":"path-helpers.d.ts","sourceRoot":"","sources":["../src/path-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAgB,MAAM,SAAS,CAAC;AAKlD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAgBzC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,GACxC,MAAM,CAiBR;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAmBxD"}
@@ -36,13 +36,19 @@ import { tmpdir } from 'node:os';
36
36
  export function normalizedTmpdir() {
37
37
  const temp = tmpdir();
38
38
  try {
39
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- Safe: temp is from tmpdir() (OS-provided system temp directory), not user input
40
- return realpathSync(temp);
39
+ // Use native OS realpath for better Windows compatibility
40
+ return realpathSync.native(temp);
41
41
  }
42
42
  catch {
43
- // Fallback: if realpathSync fails, return original
44
- // (shouldn't happen, but safety first)
45
- return temp;
43
+ // Fallback to regular realpathSync
44
+ try {
45
+ // eslint-disable-next-line security/detect-non-literal-fs-filename -- Safe: temp is from tmpdir()
46
+ return realpathSync(temp);
47
+ }
48
+ catch {
49
+ // Last resort: return original
50
+ return temp;
51
+ }
46
52
  }
47
53
  }
48
54
  /**
@@ -77,41 +83,64 @@ export function normalizedTmpdir() {
77
83
  * ```
78
84
  */
79
85
  export function mkdirSyncReal(path, options) {
80
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- Safe: path is function parameter from test setup (tmpdir + test name), not user input
86
+ // eslint-disable-next-line security/detect-non-literal-fs-filename -- This IS the mkdirSyncReal() implementation
81
87
  mkdirSync(path, options);
82
88
  try {
83
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- Safe: path is function parameter from test setup (tmpdir + test name), not user input
84
- return realpathSync(path);
89
+ // Use native OS realpath for better Windows compatibility
90
+ return realpathSync.native(path);
85
91
  }
86
92
  catch {
87
- // Fallback: if realpathSync fails, return original
88
- // (might happen if directory creation failed)
89
- return path;
93
+ // Fallback to regular realpathSync
94
+ try {
95
+ // eslint-disable-next-line security/detect-non-literal-fs-filename -- Safe: path is function parameter
96
+ return realpathSync(path);
97
+ }
98
+ catch {
99
+ // Last resort: return original
100
+ return path;
101
+ }
90
102
  }
91
103
  }
92
104
  /**
93
105
  * Normalize any path (resolve short names on Windows)
94
106
  *
95
107
  * Utility to normalize paths without creating directories.
96
- * Useful when you have an existing path that might contain short names.
108
+ * Accepts multiple path segments like path.resolve() for convenience.
97
109
  *
98
- * @param path - Path to normalize
99
- * @returns Real (normalized) path, or original if normalization fails
110
+ * @param paths - Path segments to join and normalize
111
+ * @returns Real (normalized) path, or resolved path if normalization fails
100
112
  *
101
113
  * @example
102
114
  * ```typescript
115
+ * // Single path
103
116
  * const shortPath = 'C:\\PROGRA~1\\nodejs';
104
117
  * const longPath = normalizePath(shortPath);
105
118
  * // Result: 'C:\\Program Files\\nodejs'
119
+ *
120
+ * // Multiple segments (like path.resolve)
121
+ * const cliPath = normalizePath(__dirname, '../../dist/bin.js');
122
+ * // Resolves to absolute path AND normalizes short names
106
123
  * ```
107
124
  */
108
- export function normalizePath(path) {
125
+ export function normalizePath(...paths) {
126
+ // First resolve to absolute path (handles multiple segments)
127
+ const resolved = paths.length === 1
128
+ ? paths[0]
129
+ : require('node:path').resolve(...paths);
109
130
  try {
110
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- Safe: path is function parameter from test setup (tmpdir + test name), not user input
111
- return realpathSync(path);
131
+ // Use native OS realpath for better Windows compatibility
132
+ return realpathSync.native(resolved);
112
133
  }
113
134
  catch {
114
- return path;
135
+ // Fallback to regular realpathSync
136
+ try {
137
+ // eslint-disable-next-line security/detect-non-literal-fs-filename -- Safe: resolved is from path.resolve
138
+ return realpathSync(resolved);
139
+ }
140
+ catch {
141
+ // Last resort: return resolved path (better than original input)
142
+ return resolved;
143
+ }
115
144
  }
116
145
  }
117
146
  //# sourceMappingURL=path-helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"path-helpers.js","sourceRoot":"","sources":["../src/path-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC;IACtB,IAAI,CAAC;QACH,sJAAsJ;QACtJ,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,mDAAmD;QACnD,uCAAuC;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAY,EACZ,OAAyC;IAEzC,4JAA4J;IAC5J,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAEzB,IAAI,CAAC;QACH,4JAA4J;QAC5J,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,mDAAmD;QACnD,8CAA8C;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,IAAI,CAAC;QACH,4JAA4J;QAC5J,OAAO,YAAY,CAAC,IAAI,CAAC,CA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,KAAe;IAC9C,6DAA6D;IAC7D,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,KAAK,CAAC;QACjC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACV,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;IAE3C,IAAI,CAAC;QACH,0DAA0D;QAC1D,OAAO,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,mCAAmC;QACnC,IAAI,CAAC;YACH,0GAA0G;YAC1G,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;QAAC,MAAM,CAAC;YACP,iEAAiE;YACjE,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-validate/utils",
3
- "version": "0.17.6",
3
+ "version": "0.18.0-rc.1",
4
4
  "description": "Common utilities for vibe-validate packages (command execution, path normalization)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",