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

View File

@@ -125,9 +125,6 @@ async function ImportJob(filepath: string): Promise<void> {
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 = {
uploaded_by: store.get("user.email"),
bodyshopid: store.get("app.bodyshop.id"),