mantra/.gulp/Settings.ts

126 lines
2.6 KiB
TypeScript
Raw Normal View History

2019-10-07 11:48:01 +00:00
import Path = require("upath");
/**
* Provides settings for building the project.
*/
export class Settings
{
/**
* A value indicating whether the project should be built in watched mode.
*/
public Watch = false;
/**
* The target of the project-build.
*/
public Target: string;
/**
* The path to the source-code root.
*/
private sourceRoot = "src";
/**
* The path to the root of the typescript-project.
*/
private typeScriptProjectRoot = "App";
/**
* The path to the root of the typescript-source.
*/
private typeScriptSourceRoot = "src";
/**
* The path to save the javascript-code to.
*/
private libraryPath = "javascript";
/**
* Initializes a new instance of the `Settings` class.
*
* @param target
* The target of the project-build.
*/
public constructor(target: string)
{
this.Target = target;
}
/**
* A value indicating whether the debug-mode is enabled.
*/
public get Debug()
{
return this.Target === "Debug";
}
/**
* Creates a path relative to the root of the solution.
*
* @param path
* The path to join.
*
* @return
* The joined path.
*/
public RootPath(...path: string[])
{
return Path.join(Path.dirname(__dirname), ...path);
}
/**
* Creates a path relative to the root of the source-code.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
public SourceRoot(...path: string[])
{
return this.RootPath(this.sourceRoot, ...path);
}
/**
* Creates a path relative to the root of the typescript-project.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
public TypeScriptProjectRoot(...path: string[])
{
return this.SourceRoot(this.typeScriptProjectRoot, ...path);
}
/**
* Creates a path relative to the root of the typescript-source.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
public TypeScriptSourceRoot(...path: string[])
{
return this.TypeScriptProjectRoot(this.typeScriptSourceRoot, ...path);
}
/**
* Creates a path relative to the directory to save the javascript-code to.
*
* @param path
* The path to join.
*
* @returns
* The joined path.
*/
public LibraryPath(...path: string[])
{
return this.RootPath(this.libraryPath, ...path);
}
}