You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-30 02:21:17 +03:00
Ensure component index has been written before renaming
This ensures we correctly wait for `component-index.js.tmp` to be written to disk before trying to rename into place. This fixes an issue where stray temp files were being strewn about the repos after renaming failures.
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const glob = require('glob');
|
||||
const util = require('util');
|
||||
const args = require('minimist')(process.argv);
|
||||
const chokidar = require('chokidar');
|
||||
|
||||
@ -12,7 +13,7 @@ const componentJsGlob = '**/*.js';
|
||||
const componentTsGlob = '**/*.tsx';
|
||||
let prevFiles = [];
|
||||
|
||||
function reskindex() {
|
||||
async function reskindex() {
|
||||
const jsFiles = glob.sync(componentJsGlob, {cwd: componentsDir}).sort();
|
||||
const tsFiles = glob.sync(componentTsGlob, {cwd: componentsDir}).sort();
|
||||
const files = [...tsFiles, ...jsFiles];
|
||||
@ -51,7 +52,8 @@ function reskindex() {
|
||||
}
|
||||
|
||||
strm.write("export {components};\n");
|
||||
strm.end();
|
||||
// Ensure the file has been fully written to disk before proceeding
|
||||
await util.promisify(strm.end);
|
||||
fs.rename(componentIndexTmp, componentIndex, function(err) {
|
||||
if (err) {
|
||||
console.error("Error moving new index into place: " + err);
|
||||
|
Reference in New Issue
Block a user