mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-17 09:00:06 +00:00
fix(path): make log file path platform-agnostic
This commit is contained in:
@@ -8,7 +8,8 @@ export const getFileStream = async (job: Job, filePath?: string) => {
|
|||||||
const isFolderPath = await isFolder(logPath)
|
const isFolderPath = await isFolder(logPath)
|
||||||
if (isFolderPath) {
|
if (isFolderPath) {
|
||||||
const logFileName = `${job.name || 'job'}-${generateTimestamp()}.log`
|
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)
|
return await createWriteStream(logFilePath)
|
||||||
} else {
|
} else {
|
||||||
return await createWriteStream(logPath)
|
return await createWriteStream(logPath)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ describe('getFileStream', () => {
|
|||||||
|
|
||||||
expect(createWriteStream).not.toHaveBeenCalledWith(__dirname)
|
expect(createWriteStream).not.toHaveBeenCalledWith(__dirname)
|
||||||
expect(createWriteStream).toHaveBeenCalledWith(
|
expect(createWriteStream).toHaveBeenCalledWith(
|
||||||
expect.stringContaining(__dirname + '/test job-20')
|
expect.stringContaining(path.join(__dirname, '/test job-20'))
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user