UNPKG

@toreda/build-tools

Version:

![Toreda](https://content.toreda.com/logo/toreda-logo.png)

64 lines (63 loc) 2.75 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Build = void 0; const clean_1 = require("./clean"); const cli_1 = require("./cli"); const config_1 = require("./config"); const create_1 = require("./create"); const events_1 = require("events"); const steps_1 = require("./gulp/steps"); const linter_1 = require("./linter"); const log_1 = require("@toreda/log"); const run_1 = require("./run"); const contents_1 = require("./file/contents"); class Build { constructor(options) { this.events = this.initEvents(); this.log = this.initLog(options); this.cli = new cli_1.Cli(this.log); this.cfg = this.initConfig(this.cli.getArgs(), options, this.log); this.run = new run_1.Run(this.cfg, this.events, this.log); this.clean = new clean_1.Clean(this.cfg, this.events, this.log); this.create = new create_1.Create(this.cfg, this.events, this.log); this.linter = new linter_1.Linter(this.cfg, this.events, this.log); this.gulpSteps = new steps_1.GulpSteps(this.run, this.create, this.linter, this.clean, this.log); } initLog(options) { if (!options || !options.log) { return new log_1.Log().makeLog('Build'); } if (!(options.log instanceof log_1.Log)) { return new log_1.Log(options.log).makeLog('Build'); } return options.log.makeLog('Build'); } initEvents(options) { if (!options || !options.events) { return new events_1.EventEmitter(); } if (!(options.events instanceof events_1.EventEmitter)) { return new events_1.EventEmitter(); } return options.events; } initConfig(args, options, baseLog) { const log = baseLog.makeLog('initConfig'); return new config_1.Config(args, options, log); } getContents(path, options) { return __awaiter(this, void 0, void 0, function* () { return (0, contents_1.fileContents)(path, options); }); } } exports.Build = Build;