UNPKG

@criticalmanufacturing/dev-i18n-transform

Version:
45 lines 1.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const path = require("path"); class Package { /** * Creates a new Package structure * @param packagePath Name of the package */ constructor(packagePath) { this._files = {}; this.path = path.normalize(packagePath); this.name = path.basename(packagePath); } /** * Gets all package files */ get files() { return Object.keys(this._files).map((index) => { return this._files[index]; }); } /** * Verify if the given file already exists in the package * @param file File to check if exists * @return True if the file exists, false otherwise */ hasFile(file) { return file.uniqueFileName in this._files; } /** * Adds a file to the package. * If the a file with the same with the same identifier already exists in the package, it's merged {@see File.merge} with the existing one. * @param file File to be added or updated. */ addOrUpdateFile(file) { if (this.hasFile(file)) { this._files[file.uniqueFileName].merge(file); } else { this._files[file.uniqueFileName] = file; } } } exports.Package = Package; //# sourceMappingURL=package.js.map