From a6958fea572fdf357f54d5ef87015a54a020a9c9 Mon Sep 17 00:00:00 2001 From: gventurini Date: Wed, 28 Feb 2024 14:34:55 +0100 Subject: [PATCH] write file allows to specify filesystem flags --- src/util/file-system-utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/file-system-utils.ts b/src/util/file-system-utils.ts index 56fb9846..48ee017c 100644 --- a/src/util/file-system-utils.ts +++ b/src/util/file-system-utils.ts @@ -38,10 +38,10 @@ export class FileSystemUtils { this.writeFile(filePath, prettyJson); } - static writeFile(filePath: string, data: string): void { + static writeFile(filePath: string, data: string, flag: string = 'w'): void { const fileDirectory = path.dirname(filePath); this.createFolderIfNotExists(fileDirectory); - fs.writeFileSync(filePath, data, {encoding:'utf8'}); + fs.writeFileSync(filePath, data, { encoding: 'utf8', flag: flag }); } static createFolderIfNotExists(folderPath: string): void {