From 79a55f64d4c8eadbde5377192c359eaa340a6209 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Sun, 9 Jun 2019 23:41:20 +0200 Subject: [PATCH] Fixed wrong variables, added initialization --- src/factory.ts | 10 ++++++---- src/pass.ts | 12 +++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/factory.ts b/src/factory.ts index 150dad2..4463937 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -65,7 +65,7 @@ async function getModelFolderContents(model: string): Promise 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 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 const L10N_FilesListByFolder: Array = 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 { + .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"}); diff --git a/src/pass.ts b/src/pass.ts index bfba123..af6d8f2 100644 --- a/src/pass.ts +++ b/src/pass.ts @@ -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; - private passCore: schema.ValidPass; + private _props: schema.ValidPass = {}; + private type: string = ""; + private fieldsKeys: Set = new Set(); + 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();