Initial commit
This commit is contained in:
commit
78f8d225ee
21173 changed files with 2907774 additions and 0 deletions
18
node_modules/next/dist/esm/lib/fs/write-atomic.js
generated
vendored
Normal file
18
node_modules/next/dist/esm/lib/fs/write-atomic.js
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { unlink, writeFile } from 'fs/promises';
|
||||
import { rename } from './rename';
|
||||
export async function writeFileAtomic(filePath, content) {
|
||||
const tempPath = filePath + '.tmp.' + Math.random().toString(36).slice(2);
|
||||
try {
|
||||
await writeFile(tempPath, content, 'utf-8');
|
||||
await rename(tempPath, filePath);
|
||||
} catch (e) {
|
||||
try {
|
||||
await unlink(tempPath);
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=write-atomic.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue