mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-15 20:54:59 +08: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:
parent
0e137bd0f6
commit
4e5f25206a
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user