mirror of
https://github.com/sasjs/server.git
synced 2026-01-07 06:30:06 +00:00
chore: code fixes
This commit is contained in:
18
api/src/utils/getRunTimeAndFilePath.ts
Normal file
18
api/src/utils/getRunTimeAndFilePath.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import path from 'path'
|
||||
import { fileExists } from '@sasjs/utils'
|
||||
import { getFilesFolder } from './file'
|
||||
|
||||
export const getRunTimeAndFilePath = async (programPath: string) => {
|
||||
for (const runTime of process.runTimes) {
|
||||
const codePath =
|
||||
path
|
||||
.join(getFilesFolder(), programPath)
|
||||
.replace(new RegExp('/', 'g'), path.sep) +
|
||||
'.' +
|
||||
runTime
|
||||
|
||||
if (await fileExists(codePath)) return { codePath, runTime }
|
||||
}
|
||||
|
||||
throw `The Program at (${programPath}) does not exist.`
|
||||
}
|
||||
Reference in New Issue
Block a user