From 626fc2e15f0a51cc7e8bed05e0f0b46683ef52e6 Mon Sep 17 00:00:00 2001 From: Krishna Acondy Date: Sat, 24 Jul 2021 09:53:39 +0100 Subject: [PATCH] fix(path): make log file path platform-agnostic --- src/api/viya/getFileStream.ts | 3 ++- src/api/viya/spec/getFileStream.spec.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/api/viya/getFileStream.ts b/src/api/viya/getFileStream.ts index 620ddc0..c647f3e 100644 --- a/src/api/viya/getFileStream.ts +++ b/src/api/viya/getFileStream.ts @@ -8,7 +8,8 @@ export const getFileStream = async (job: Job, filePath?: string) => { const isFolderPath = await isFolder(logPath) if (isFolderPath) { const logFileName = `${job.name || 'job'}-${generateTimestamp()}.log` - const logFilePath = `${filePath || process.cwd()}/${logFileName}` + const path = require('path') + const logFilePath = path.join(filePath || process.cwd(), logFileName) return await createWriteStream(logFilePath) } else { return await createWriteStream(logPath) diff --git a/src/api/viya/spec/getFileStream.spec.ts b/src/api/viya/spec/getFileStream.spec.ts index 0722e37..a05b5cb 100644 --- a/src/api/viya/spec/getFileStream.spec.ts +++ b/src/api/viya/spec/getFileStream.spec.ts @@ -27,7 +27,7 @@ describe('getFileStream', () => { expect(createWriteStream).not.toHaveBeenCalledWith(__dirname) expect(createWriteStream).toHaveBeenCalledWith( - expect.stringContaining(__dirname + '/test job-20') + expect.stringContaining(path.join(__dirname, '/test job-20')) ) }) })