Unlink scripts submodule and commit contents as normal directory
This commit is contained in:
1 parent
4f7dea111f
commit
6488b3ea85
48 files changed
+2876
-1
No files matched your search
@@ -0,0 +1,20 @@
|
||||
const fs = require('node:fs/promises');
|
||||
const path = require('node:path');
|
||||
|
||||
const queues = new Map();
|
||||
|
||||
const queueWrite = (filePath, fn) => {
|
||||
const key = path.resolve(filePath);
|
||||
const prev = queues.get(key) || Promise.resolve();
|
||||
const next = prev.then(fn, fn);
|
||||
queues.set(key, next);
|
||||
return next;
|
||||
};
|
||||
|
||||
const atomicWriteFile = async (filePath, data) => {
|
||||
const tmp = `${filePath}.tmp`;
|
||||
await fs.writeFile(tmp, data);
|
||||
await fs.rename(tmp, filePath);
|
||||
};
|
||||
|
||||
module.exports = { queueWrite, atomicWriteFile };
|
||||
Reference in new issue
Block a user