@manuth/woltlab-compiler
Version:
A compiler for generating WoltLab-Package `.tar` Archives and other WoltLab-Package Components
71 lines • 1.87 kB
JavaScript
import path from "upath";
import { FileSystemInstructionCompiler } from "../../../Compilation/PackageSystem/Instructions/FileSystemInstructionCompiler.js";
import { Instruction } from "../Instruction.js";
const { basename, isAbsolute, normalize, sep } = path;
/**
* Represents an instruction which is bound to a file-system entry.
*/
export class FileSystemInstruction extends Instruction {
/**
* Initializes a new instance of the {@link FileSystemInstruction `FileSystemInstruction`} class.
*
* @param options
* The options of the file-system instruction.
*/
constructor(options) {
super({
FileName: options.FileName
});
this.Source = options.Source;
}
/**
* Gets or sets the path to the file-system entry the instruction is bound to.
*/
get Source() {
return this.source;
}
/**
* @inheritdoc
*/
set Source(value) {
this.source = value;
}
/**
* @inheritdoc
*/
get FileName() {
var _a;
return (_a = super.FileName) !== null && _a !== void 0 ? _a : this.MakeDefaultFileName(this.Source);
}
/**
* @inheritdoc
*/
set FileName(value) {
super.FileName = value;
}
/**
* @inheritdoc
*/
get Compiler() {
return new FileSystemInstructionCompiler(this);
}
/**
* Creates a default file-name based on the source of the instruction.
*
* @param source
* The source of the instruction.
*
* @returns
* The default filename.
*/
MakeDefaultFileName(source) {
if (isAbsolute(source) ||
(normalize(source).split(sep)[0] === "..")) {
return basename(source);
}
else {
return source;
}
}
}
//# sourceMappingURL=FileSystemInstruction.js.map