@nomiclabs/buidler
Version:
Buidler is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.
50 lines • 1.67 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const task_definitions_1 = require("./task-definitions");
/**
* This class defines the DSL used in Buidler config files
* for creating and overriding tasks.
*/
class TasksDSL {
constructor() {
this._tasks = {};
}
task(name, descriptionOrAction, action) {
return this._addTask(name, descriptionOrAction, action, false);
}
internalTask(name, descriptionOrAction, action) {
return this._addTask(name, descriptionOrAction, action, true);
}
/**
* Retrieves the task definitions.
*
* @returns The tasks container.
*/
getTaskDefinitions() {
return this._tasks;
}
_addTask(name, descriptionOrAction, action, isInternal) {
const parentTaskDefinition = this._tasks[name];
let taskDefinition;
if (parentTaskDefinition !== undefined) {
taskDefinition = new task_definitions_1.OverriddenTaskDefinition(parentTaskDefinition, isInternal);
}
else {
taskDefinition = new task_definitions_1.SimpleTaskDefinition(name, isInternal);
}
if (descriptionOrAction instanceof Function) {
action = descriptionOrAction;
descriptionOrAction = undefined;
}
if (descriptionOrAction !== undefined) {
taskDefinition.setDescription(descriptionOrAction);
}
if (action !== undefined) {
taskDefinition.setAction(action);
}
this._tasks[name] = taskDefinition;
return taskDefinition;
}
}
exports.TasksDSL = TasksDSL;
//# sourceMappingURL=dsl.js.map
;