fix(windows): make native coverage graph portable
This commit is contained in:
@@ -14,7 +14,7 @@ describe('writeFileAtomic', () => {
|
||||
const target = join(dir, 'nested', 'deep', 'doc.yaml')
|
||||
await writeFileAtomic(target, 'a: 1\n', { mode: 0o600 })
|
||||
expect(await readFile(target, 'utf8')).toBe('a: 1\n')
|
||||
expect((await stat(target)).mode & 0o777).toBe(0o600)
|
||||
if (process.platform !== 'win32') expect((await stat(target)).mode & 0o777).toBe(0o600)
|
||||
})
|
||||
|
||||
it('replaces existing content and narrows a wider-permission file to the stated mode', async () => {
|
||||
@@ -23,7 +23,7 @@ describe('writeFileAtomic', () => {
|
||||
await writeFile(target, 'old', { mode: 0o644 })
|
||||
await writeFileAtomic(target, 'new', { mode: 0o600 })
|
||||
expect(await readFile(target, 'utf8')).toBe('new')
|
||||
expect((await stat(target)).mode & 0o777).toBe(0o600)
|
||||
if (process.platform !== 'win32') expect((await stat(target)).mode & 0o777).toBe(0o600)
|
||||
})
|
||||
|
||||
it('replaces a symlinked target itself without writing through to the referent', async () => {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* @module @deepseek-ai/dsh-paths
|
||||
*/
|
||||
|
||||
import { realpath } from 'node:fs/promises'
|
||||
import { opendir, realpath } from 'node:fs/promises'
|
||||
import { homedir } from 'node:os'
|
||||
import { basename, dirname, join, resolve } from 'node:path'
|
||||
|
||||
@@ -32,7 +32,12 @@ export async function canonicalizeWatchPath(path: string): Promise<string> {
|
||||
const missing: string[] = []
|
||||
while (true) {
|
||||
try {
|
||||
return join(await realpath(current), ...missing.reverse())
|
||||
const canonical = await realpath(current)
|
||||
if (missing.length > 0) {
|
||||
const directory = await opendir(canonical)
|
||||
await directory.close()
|
||||
}
|
||||
return join(canonical, ...missing.reverse())
|
||||
} catch (error) {
|
||||
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error
|
||||
const parent = dirname(current)
|
||||
|
||||
Reference in New Issue
Block a user