UNPKG

kaven-utils

Version:

Utils for Node.js.

42 lines (41 loc) 1.26 kB
/******************************************************************** * @author: Kaven * @email: kaven@wuwenkai.com * @website: http://blog.kaven.xyz * @file: [Kaven-Utils] /src/GeneratedFile.ts * @create: 2022-04-21 16:50:47.915 * @modify: 2023-12-06 14:57:08.203 * @version: 5.4.0 * @times: 7 * @lines: 52 * @copyright: Copyright © 2022-2023 Kaven. All Rights Reserved. * @description: [description] * @license: [license] ********************************************************************/ import { CopyFile, GetFileContent, TryDeleteFile } from "./KavenUtility.FileSystem.js"; export class GeneratedFile { content; Path; constructor(path) { this.Path = path; } async GetContent(force = false) { if (!force && this.content) { return this.content; } this.content = await GetFileContent(this.Path); return this.content; } async Delete() { return await TryDeleteFile(this.Path); } async CopyTo(dest) { return await CopyFile(this.Path, dest); } async MoveTo(dest) { if (await this.CopyTo(dest)) { return await this.Delete(); } return false; } }