woltlab-compiler
Version:
A compiler for WoltLab-Package Archives and WoltLab-Package Components
70 lines • 2.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const Path = require("path");
const UPath = require("upath");
const util_1 = require("util");
const FileSystemInstructionCompiler_1 = require("../../../Compilation/PackageSystem/Instructions/FileSystemInstructionCompiler");
const Instruction_1 = require("../Instruction");
/**
* Represents an instruction which is bound to a file-system entry.
*/
class FileSystemInstruction extends Instruction_1.Instruction {
/**
* Initializes a new instance of the `FileSystemInstruction` class.
*/
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;
}
set Source(value) {
this.source = value;
}
/**
* @inheritdoc
*/
get FileName() {
if (util_1.isNullOrUndefined(super.FileName)) {
return this.MakeDefaultFileName(this.Source);
}
else {
return super.FileName;
}
}
/**
* @inheritdoc
*/
set FileName(value) {
super.FileName = value;
}
/**
* @inheritdoc
*/
get Compiler() {
return new FileSystemInstructionCompiler_1.FileSystemInstructionCompiler(this);
}
/**
* Creates a default file-name based on the source of the instruction.
*
* @param source
* The source of the instruction.
*/
MakeDefaultFileName(source) {
if (Path.isAbsolute(source) ||
(UPath.normalize(source).split(UPath.sep)[0] === "..")) {
return Path.basename(source);
}
else {
return source;
}
}
}
exports.FileSystemInstruction = FileSystemInstruction;
//# sourceMappingURL=FileSystemInstruction.js.map