Resolve file path resolution on Mac/Linux.

This commit is contained in:
Patrick Fic
2025-04-09 15:01:31 -07:00
parent ca1d3ffec9
commit 0cbecb1d6c
2 changed files with 15 additions and 7 deletions

View File

@@ -8,13 +8,17 @@ const findFileCaseInsensitive = async (
): Promise<string | null> => { ): Promise<string | null> => {
const directory: string = path.dirname(extensionlessFilePath); const directory: string = path.dirname(extensionlessFilePath);
try { try {
const matchingFiles = fs const matchingFiles = fs.readdirSync(directory).filter((file: string) => {
.readdirSync(directory) return (
.filter((file: string) =>
extensions.some((ext) => extensions.some((ext) =>
file.toLowerCase().endsWith(ext.toLowerCase()), file.toLowerCase().endsWith(ext.toLowerCase()),
), ) &&
path
.basename(file, path.extname(file))
.toLowerCase()
.startsWith(path.basename(extensionlessFilePath).toLowerCase())
); );
});
const files: string[] = []; const files: string[] = [];
matchingFiles.forEach((file) => { matchingFiles.forEach((file) => {
const fullPath = path.join(directory, file); const fullPath = path.join(directory, file);
@@ -33,4 +37,11 @@ const findFileCaseInsensitive = async (
return null; return null;
}; };
const getFilePathWithoutExtension = (filePath: string): string => {
return path.join(
path.dirname(filePath),
path.basename(filePath, path.extname(filePath)),
);
};
export { findFileCaseInsensitive }; export { findFileCaseInsensitive };

View File

@@ -125,9 +125,6 @@ async function ImportJob(filepath: string): Promise<void> {
log.info(`Job data saved to: ${filePath}`); log.info(`Job data saved to: ${filePath}`);
} }
//Temporarily adjust the claim number to ensure we are running on the right set of claims.
jobObject.clm_no = `ELECTRONAPP-${jobObject.clm_no}`;
const newAvailableJob: AvailableJobSchema = { const newAvailableJob: AvailableJobSchema = {
uploaded_by: store.get("user.email"), uploaded_by: store.get("user.email"),
bodyshopid: store.get("app.bodyshop.id"), bodyshopid: store.get("app.bodyshop.id"),