mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 19:25:23 +00:00
Fixed serverless model reading .pass extensions issues
This commit is contained in:
@@ -27,7 +27,16 @@ export async function getModel(
|
|||||||
): Promise<string | { [key: string]: Buffer }> {
|
): Promise<string | { [key: string]: Buffer }> {
|
||||||
if (process.env.IS_OFFLINE === "true") {
|
if (process.env.IS_OFFLINE === "true") {
|
||||||
console.log("model offline retrieving");
|
console.log("model offline retrieving");
|
||||||
return path.resolve(__dirname, "../../../", `models/${modelName}`);
|
|
||||||
|
const standardModelName = modelName.endsWith(".pass")
|
||||||
|
? modelName
|
||||||
|
: `${modelName}.pass`;
|
||||||
|
|
||||||
|
return path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"../../../",
|
||||||
|
`models/${standardModelName}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const s3 = await getS3Instance();
|
const s3 = await getS3Instance();
|
||||||
@@ -127,7 +136,7 @@ export async function getSpecificFileInModel(
|
|||||||
const model = await getModel(modelName);
|
const model = await getModel(modelName);
|
||||||
|
|
||||||
if (typeof model === "string") {
|
if (typeof model === "string") {
|
||||||
return fs.readFile(path.resolve(`${model}.pass`, fileName));
|
return fs.readFile(path.resolve(model, fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
return model[fileName];
|
return model[fileName];
|
||||||
|
|||||||
Reference in New Issue
Block a user