@criticalmanufacturing/node-package-bundler
Version:
Connect IoT Package Bundler
48 lines • 2.5 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LibraryFontProcessor = void 0;
const log_1 = require("./log");
const io = require("fs-extra");
const inversify_1 = require("inversify");
const types_1 = require("../types");
const paths_1 = require("./paths");
let LibraryFontProcessor = class LibraryFontProcessor {
constructor() {
this._finalTemplates = {};
}
process(fontConfigPath, destination) {
var _a;
fontConfigPath = this._paths.transform(fontConfigPath);
this._logger.info(` [Font] Processing library font in '${fontConfigPath}'`);
const fontContent = io.readJSONSync(fontConfigPath);
const json = io.readJSONSync(destination);
if (((_a = json === null || json === void 0 ? void 0 : json.criticalManufacturing) === null || _a === void 0 ? void 0 : _a.tasksLibrary) == null) {
throw new Error("Unable to read TasksLibrary section of the package.json file");
}
const libraryMetadata = json.criticalManufacturing.tasksLibrary;
libraryMetadata.metadata["font"] = fontContent;
io.writeFileSync(destination, JSON.stringify(json, null, 2), "utf8");
}
};
exports.LibraryFontProcessor = LibraryFontProcessor;
__decorate([
(0, inversify_1.inject)(types_1.TYPES.Logger),
__metadata("design:type", log_1.Log)
], LibraryFontProcessor.prototype, "_logger", void 0);
__decorate([
(0, inversify_1.inject)(types_1.TYPES.Paths),
__metadata("design:type", paths_1.Paths)
], LibraryFontProcessor.prototype, "_paths", void 0);
exports.LibraryFontProcessor = LibraryFontProcessor = __decorate([
(0, inversify_1.injectable)()
], LibraryFontProcessor);
//# sourceMappingURL=libraryFont.js.map