Skip to content

Commit

Permalink
fix(EntityModel): create the folder structure before attempting to wr…
Browse files Browse the repository at this point in the history
…ite the generated ftl file
  • Loading branch information
meszaros-lajos-gyorgy committed Aug 19, 2023
1 parent ae04634 commit 91a0fcf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/EntityModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ export class EntityModel {
return files
}

// TODO: this is the same as Texture.createCacheFolderIfNotExists
private async createCacheFolderIfNotExists(folder: string) {
try {
await fs.promises.access(folder, fs.promises.constants.R_OK | fs.promises.constants.W_OK)
} catch (e) {
await fs.promises.mkdir(folder, { recursive: true })
}
}

/**
* this method assumes that this.treeJsObj is defined
*/
Expand Down Expand Up @@ -190,6 +199,7 @@ export class EntityModel {
}

const ftl = FTL.save(ftlData)
await this.createCacheFolderIfNotExists(path.dirname(target))
await fs.promises.writeFile(target, ftl)

return target
Expand Down

0 comments on commit 91a0fcf

Please sign in to comment.