1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-11 01:14:36 +00:00

fix(path): make log file path platform-agnostic

This commit is contained in:
Krishna Acondy
2021-07-24 09:53:39 +01:00
parent 87e2edbd6c
commit 626fc2e15f
2 changed files with 3 additions and 2 deletions

View File

@@ -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)

View File

@@ -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'))
)
})
})