UNPKG

@manuth/woltlab-compiler

Version:

A compiler for generating WoltLab-Package `.tar` Archives and other WoltLab-Package Components

55 lines 1.38 kB
import path from "upath"; const { basename, isAbsolute, normalize, resolve, sep } = path; /** * Provides a description of a file. */ export class FileDescriptor { /** * Initializes a new instance of the {@link FileDescriptor `FileDescriptor`} class. * * @param options * The options of the file-descriptor. */ constructor(options) { this.Source = resolve(options.Source); if ((options.FileName !== null) && (options.FileName !== undefined)) { this.FileName = options.FileName; } else { let fileName = normalize(options.Source); if (isAbsolute(fileName) || (normalize(fileName).split(sep)[0] === "..")) { this.FileName = basename(fileName); } else { this.FileName = fileName; } } } /** * Gets or sets the path to load the file from. */ get Source() { return this.source; } /** * @inheritdoc */ set Source(value) { this.source = value; } /** * Gets ort sets the filename to save the file to. */ get FileName() { return this.fileName; } /** * @inheritdoc */ set FileName(value) { this.fileName = value; } } //# sourceMappingURL=FileDescriptor.js.map