@manuth/woltlab-compiler
Version:
A compiler for generating WoltLab-Package `.tar` Archives and other WoltLab-Package Components
84 lines • 2.28 kB
JavaScript
import path from "upath";
import { FileInstructionCompiler } from "../../../Compilation/PackageSystem/Instructions/FileInstructionCompiler.js";
import { FileSystemInstruction } from "./FileSystemInstruction.js";
const { join } = path;
/**
* Represents an instruction which uploads files for a specific application.
*/
export class ApplicationFileSystemInstruction extends FileSystemInstruction {
/**
* Initializes a new instance of the {@link ApplicationFileSystemInstruction `ApplicationFileSystemInstruction`}.
*
* @param options
* The options of the application file-system instruction.
*/
constructor(options) {
super({
Source: options.Source,
FileName: options.FileName
});
/**
* The application to upload the files to.
*/
this.application = null;
if ((options.Application !== null) &&
(options.Application !== undefined)) {
this.Application = options.Application;
}
}
/**
* @inheritdoc
*/
get Type() {
return "file";
}
/**
* Gets or sets the application to upload the files to.
*/
get Application() {
return this.application;
}
/**
* @inheritdoc
*/
set Application(value) {
this.application = value;
}
/**
* @inheritdoc
*/
get Compiler() {
return new FileInstructionCompiler(this);
}
/**
* Gets the name of the directory to save the assets archive to.
*/
get AssetDirectoryName() {
return "files";
}
/**
* @inheritdoc
*
* @param source
* The source of the instruction.
*
* @returns
* The default filename.
*/
MakeDefaultFileName(source) {
return join(this.AssetDirectoryName, ...(this.Application ? [this.Application] : []), `${this.GetAssetFileName(source)}.tar`);
}
/**
* Gets the default name of the asset file.
*
* @param source
* The source of the instruction.
*
* @returns
* The default name of the asset file.
*/
GetAssetFileName(source) {
return super.MakeDefaultFileName(source);
}
}
//# sourceMappingURL=ApplicationFileSystemInstruction.js.map