Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

test: pass Windows short-path command verbatim

sunsunsun798f871a0f3b
diff --git a/archify/test/preview.test.mjs b/archify/test/preview.test.mjs
index d3919223..07961f50 100644
--- a/archify/test/preview.test.mjs
+++ b/archify/test/preview.test.mjs
@@ -19,23 +19,18 @@ function sha256(file) {
return createHash('sha256').update(fs.readFileSync(file)).digest('hex');
}
-function windowsShortPathFromOutput(stdout) {
- const output = stdout.trim();
- if (output.length >= 2 && output.startsWith('"') && output.endsWith('"')) {
- return output.slice(1, -1);
- }
- return output;
-}
-
function windowsShortPath(targetPath) {
if (process.platform !== 'win32') return null;
const result = spawnSync(
process.env.ComSpec || 'cmd.exe',
- ['/d', '/s', '/c', 'for %I in ("%ARCHIFY_SHORT_PATH_TARGET%") do @echo %~sI'],
+ ['/d', '/s', '/c', '"for %I in ("%ARCHIFY_SHORT_PATH_TARGET%") do @echo %~sI"'],
{
encoding: 'utf8',
env: { ...process.env, ARCHIFY_SHORT_PATH_TARGET: targetPath },
windowsHide: true,
+ // cmd.exe does not understand the CRT-style backslash escaping that
+ // Node otherwise applies to argv containing quotes.
+ windowsVerbatimArguments: true,
},
);
if (result.error) throw new Error(`Could not query a Windows 8.3 path: ${result.error.message}`);
@@ -43,7 +38,7 @@ function windowsShortPath(targetPath) {
const detail = result.stderr.trim() || 'no stderr';
throw new Error(`Could not query a Windows 8.3 path (exit ${result.status}): ${detail}`);
}
- const shortPath = windowsShortPathFromOutput(result.stdout);
+ const shortPath = result.stdout.trim();
if (!shortPath) throw new Error('Windows returned an empty 8.3 path');
if (path.resolve(shortPath).toLowerCase() === path.resolve(targetPath).toLowerCase()) return null;
if (fs.realpathSync.native(shortPath).toLowerCase() !== fs.realpathSync.native(targetPath).toLowerCase()) {
@@ -52,12 +47,6 @@ function windowsShortPath(targetPath) {
return shortPath;
}
-test('preview: Windows 8.3 short path discovery strips cmd quoting', () => {
- const shortPath = 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\ARCHIF~1\\DIRECT~1';
- assert.equal(windowsShortPathFromOutput(`"${shortPath}"\r\n`), shortPath);
- assert.equal(windowsShortPathFromOutput(`${shortPath}\r\n`), shortPath);
-});
-
async function stateAt(url) {
const response = await fetch(new URL('/state', url));
assert.equal(response.status, 200);