fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #373 from hey-api/fix/remove-file-if-empty

fix: remove file if no contents to write to it

authored by

Jordan Shatford and committed by
GitHub
26a8914b 12b7bf86

+11 -1
+5
.changeset/clean-books-wash.md
··· 1 + --- 2 + "@hey-api/openapi-ts": patch 3 + --- 4 + 5 + fix: remove file if no contents to write to it
+6 -1
packages/openapi-ts/src/compiler/index.ts
··· 1 - import { PathLike, writeFileSync } from 'node:fs'; 1 + import { PathLike, rmSync, writeFileSync } from 'node:fs'; 2 2 3 3 import ts from 'typescript'; 4 4 ··· 49 49 public write(seperator = '\n') { 50 50 // TODO: throw if path is not set. do not throw if items are empty 51 51 if (!this._items.length || !this._path) { 52 + this.remove({ force: true }); 52 53 return; 53 54 } 54 55 writeFileSync(this._path, this.toString(seperator)); 56 + } 57 + 58 + public remove(options?: Parameters<typeof rmSync>[1]) { 59 + rmSync(this._path, options); 55 60 } 56 61 } 57 62