UNPKG

@focuson/cod

Version:

A command line tool to help with the code on demand

24 lines (23 loc) 1.81 kB
#!/usr/bin/env node "use strict"; //Copyright (c)2020-2022 Philip Rice. <br />Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the Software), to dealin the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: <br />The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED AS Object.defineProperty(exports, "__esModule", { value: true }); exports.BuildCode = void 0; const TsxTransformer_1 = require("./TsxTransformer"); const JsonTransformer_1 = require("./JsonTransformer"); const Files_1 = require("./Files"); class BuildCode { static create() { let files = new Files_1.Files(); return new BuildCode(new TsxTransformer_1.TsxTransformer(files), new JsonTransformer_1.JsonTransformer(files)); } constructor(tsxTransformer, jsonTransformer) { this.buildCode = (src, skipJson) => (skipJson) ? this.validate(src, skipJson).then(() => this.tsxTransformer.loadAndtransformAllFiles(src)) : this.validate(src, skipJson).then(() => this.tsxTransformer.loadAndtransformAllFiles(src).then(this.jsonTransformer.updateJsonFiles(src))); this.tsxTransformer = tsxTransformer; this.jsonTransformer = jsonTransformer; } validate(src, skipJson) { return (skipJson) ? Promise.all([this.tsxTransformer.validate(src)]) : Promise.all([this.tsxTransformer.validate(src), this.jsonTransformer.validate(src)]); } } exports.BuildCode = BuildCode;