* fix: retry filesystem operations on EAGAIN filesystem operations can raise EAGAIN to tell the application to try again later. This is especially often the case under ZFS. fix: move wrapped functions to graceful-fs directly * fix: retry filesystem operations on EAGAIN * fix: retry filesystem operations on EAGAIN * fix: indexed-pkg-importer * test: fix * docs: add changeset --------- Co-authored-by: Zoltan Kochan <z@kochan.io>
22 lines
432 B
TypeScript
22 lines
432 B
TypeScript
import path from 'path'
|
|
import fs from '@pnpm/graceful-fs'
|
|
|
|
const dirs = new Set()
|
|
|
|
export function writeFile (
|
|
fileDest: string,
|
|
buffer: Buffer,
|
|
mode?: number
|
|
): void {
|
|
makeDirForFile(fileDest)
|
|
fs.writeFileSync(fileDest, buffer, { mode })
|
|
}
|
|
|
|
function makeDirForFile (fileDest: string): void {
|
|
const dir = path.dirname(fileDest)
|
|
if (!dirs.has(dir)) {
|
|
fs.mkdirSync(dir, { recursive: true })
|
|
dirs.add(dir)
|
|
}
|
|
}
|