mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 16:25:21 +00:00
Added path normalization on Windows, along with some tests
This commit is contained in:
@@ -833,6 +833,16 @@ describe("PKPass", () => {
|
|||||||
expect(pass[filesSymbol]["en.lproj/pass.string"]).toBeUndefined();
|
expect(pass[filesSymbol]["en.lproj/pass.string"]).toBeUndefined();
|
||||||
expect(pass[localizationSymbol]["en"]).toBeUndefined();
|
expect(pass[localizationSymbol]["en"]).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should convert Windows paths to single UNIX slash", () => {
|
||||||
|
if (path.sep === "\\") {
|
||||||
|
pass.addBuffer("en.lproj\\icon@2x.png", Buffer.alloc(0));
|
||||||
|
|
||||||
|
expect(pass[filesSymbol]).toContain({
|
||||||
|
"en.lproj/icon@2x.png": Buffer.alloc(0),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("[importMetadataSymbol]", () => {
|
describe("[importMetadataSymbol]", () => {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Stream } from "stream";
|
import { Stream } from "stream";
|
||||||
|
import path from "path";
|
||||||
import FieldsArray from "./FieldsArray";
|
import FieldsArray from "./FieldsArray";
|
||||||
import Bundle, { filesSymbol } from "./Bundle";
|
import Bundle, { filesSymbol } from "./Bundle";
|
||||||
import getModelFolderContents from "./getModelFolderContents";
|
import getModelFolderContents from "./getModelFolderContents";
|
||||||
@@ -435,6 +436,13 @@ export default class PKPass extends Bundle {
|
|||||||
return super.addBuffer(pathName, buffer);
|
return super.addBuffer(pathName, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converting Windows path to Unix path
|
||||||
|
* @example de.lproj\\icon.png => de.lproj/icon.png
|
||||||
|
*/
|
||||||
|
|
||||||
|
const normalizedPathName = pathName.replace(path.sep, "/");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a new pass.strings file is added, we want to
|
* If a new pass.strings file is added, we want to
|
||||||
* prevent it from being merged and, instead, save
|
* prevent it from being merged and, instead, save
|
||||||
@@ -446,7 +454,7 @@ export default class PKPass extends Bundle {
|
|||||||
|
|
||||||
let match: RegExpMatchArray | null;
|
let match: RegExpMatchArray | null;
|
||||||
|
|
||||||
if ((match = pathName.match(translationsFileRegexp))) {
|
if ((match = normalizedPathName.match(translationsFileRegexp))) {
|
||||||
const [, lang] = match;
|
const [, lang] = match;
|
||||||
|
|
||||||
const parsedTranslations = Strings.parse(buffer).translations;
|
const parsedTranslations = Strings.parse(buffer).translations;
|
||||||
@@ -460,7 +468,7 @@ export default class PKPass extends Bundle {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.addBuffer(pathName, buffer);
|
return super.addBuffer(normalizedPathName, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user