Fixed wrong variables, added initialization

This commit is contained in:
Alexander Cerutti
2019-06-09 23:41:20 +02:00
parent 85e9f63907
commit 79a55f64d4
2 changed files with 11 additions and 11 deletions

View File

@@ -65,7 +65,7 @@ async function getModelFolderContents(model: string): Promise<PartitionedBundle>
const modelFilesList = await readDir(modelPath);
// No dot-starting files, manifest and signature
const filteredFiles = removeHidden(modelFilesList).filter(f => !/(manifest|signature|pass)/i.test(f));
const filteredFiles = removeHidden(modelFilesList).filter(f => !/(manifest|signature)/i.test(f));
// Icon is required to proceed
if (!(filteredFiles.length && filteredFiles.some(file => file.toLowerCase().includes("icon")))) {
@@ -77,7 +77,7 @@ async function getModelFolderContents(model: string): Promise<PartitionedBundle>
const rawBundle = filteredFiles.filter(entry => !entry.includes(".lproj"));
const l10nFolders = filteredFiles.filter(entry => entry.includes(".lproj"));
const bundleBuffers = rawBundle.map(file => readFile(path.resolve(model, file)));
const bundleBuffers = rawBundle.map(file => readFile(path.resolve(modelPath, file)));
const buffers = await Promise.all(bundleBuffers);
const bundle: BundleUnit = Object.assign({},
@@ -89,7 +89,7 @@ async function getModelFolderContents(model: string): Promise<PartitionedBundle>
const L10N_FilesListByFolder: Array<BundleUnit> = await Promise.all(
l10nFolders.map(folderPath => {
// Reading current folder
const currentLangPath = path.join(model, folderPath);
const currentLangPath = path.join(modelPath, folderPath);
return readDir(currentLangPath)
.then(files => {
// Transforming files path to a model-relative path
@@ -193,7 +193,9 @@ async function readCertificatesFromOptions(options: Certificates): Promise<Final
// We read the contents
const rawContentsPromises = Object.keys(flattenedDocs)
.map(content => {
.map(key => {
const content = flattenedDocs[key];
if (!!path.parse(content).ext) {
// The content is a path to the document
return readFile(path.resolve(content), { encoding: "utf8"});

View File

@@ -30,10 +30,10 @@ export class Pass implements PassIndexSignature {
private bundle: schema.BundleUnit;
private l10nBundles: schema.PartitionedBundle["l10nBundle"];
private _fields: string[];
private _props: schema.ValidPass;
private type: string;
private fieldsKeys: Set<string>;
private passCore: schema.ValidPass;
private _props: schema.ValidPass = {};
private type: string = "";
private fieldsKeys: Set<string> = new Set<string>();
private passCore: schema.ValidPass = {};
Certificates: schema.FinalCertificates;
l10nTranslations: { [key: string]: { [key: string]: string } } = {};
@@ -61,8 +61,6 @@ export class Pass implements PassIndexSignature {
this[transitType] = this.passCore[this.type]["transitType"];
}
this.fieldsKeys = new Set();
const typeFields = Object.keys(this.passCore[this.type]);
this._fields = ["primaryFields", "secondaryFields", "auxiliaryFields", "backFields", "headerFields"];
@@ -142,7 +140,7 @@ export class Pass implements PassIndexSignature {
let hashFlow = forge.md.sha1.create();
hashFlow.update(finalBundle[current].toString("binary"));
archive.append(current, { name: current });
archive.append(finalBundle[current], { name: current });
acc[current] = hashFlow.digest().toHex();