| 684 | }; |
| 685 | |
| 686 | export const createFile = async ( |
| 687 | outputPath: string, |
| 688 | filePath: string, |
| 689 | content: string, |
| 690 | ) => { |
| 691 | try { |
| 692 | const fullPath = path.join(outputPath, filePath); |
| 693 | if (fullPath.endsWith(path.sep) || filePath.endsWith("/")) { |
| 694 | fs.mkdirSync(fullPath, { recursive: true }); |
| 695 | return; |
| 696 | } |
| 697 | |
| 698 | const directory = path.dirname(fullPath); |
| 699 | fs.mkdirSync(directory, { recursive: true }); |
| 700 | fs.writeFileSync(fullPath, content || ""); |
| 701 | } catch (error) { |
| 702 | throw error; |
| 703 | } |
| 704 | }; |
| 705 | export const encodeBase64 = (content: string) => |
| 706 | Buffer.from(content, "utf-8").toString("base64"); |
| 707 | |