Skip to content

Commit

Permalink
fix(execute): fixed adding print output
Browse files Browse the repository at this point in the history
  • Loading branch information
YuryShkoda committed May 2, 2023
1 parent e78f87f commit 9aaffce
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
3 changes: 2 additions & 1 deletion api/src/controllers/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ const executeCode = async (
preProgramVariables: getPreProgramVariables(req),
vars: { ...req.query, _debug: 131 },
otherArgs: { userAutoExec },
runTime: runTime
runTime: runTime,
addPrintOutput: true
})

return result
Expand Down
12 changes: 5 additions & 7 deletions api/src/controllers/internal/Execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface ExecuteFileParams {
session?: Session
runTime: RunTimeType
forceStringResult?: boolean
isStp?: boolean
addPrintOutput?: boolean
}

interface ExecuteProgramParams extends Omit<ExecuteFileParams, 'programPath'> {
Expand All @@ -45,8 +45,7 @@ export class ExecutionController {
returnJson,
session,
runTime,
forceStringResult,
isStp
forceStringResult
}: ExecuteFileParams) {
const program = await readFile(programPath)

Expand All @@ -58,8 +57,7 @@ export class ExecutionController {
returnJson,
session,
runTime,
forceStringResult,
isStp
forceStringResult
})
}

Expand All @@ -71,7 +69,7 @@ export class ExecutionController {
session: sessionByFileUpload,
runTime,
forceStringResult,
isStp
addPrintOutput
}: ExecuteProgramParams): Promise<ExecuteReturnRaw> {
const sessionController = getSessionController(runTime)

Expand Down Expand Up @@ -133,7 +131,7 @@ export class ExecutionController {
resultParts.push(process.logsUUID)
resultParts.push(log)

if (!isStp) {
if (addPrintOutput && runTime === RunTimeType.SAS) {
const printOutputPath = path.join(session.path, 'output.lst')
const printOutput = (await fileExists(printOutputPath))
? await readFile(printOutputPath)
Expand Down
6 changes: 2 additions & 4 deletions api/src/controllers/stp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ const execute = async (
req: express.Request,
_program: string,
vars: ExecutionVars,
otherArgs?: any,
isStp?: boolean
otherArgs?: any
): Promise<string | Buffer> => {
try {
const { codePath, runTime } = await getRunTimeAndFilePath(_program)
Expand All @@ -87,8 +86,7 @@ const execute = async (
preProgramVariables: getPreProgramVariables(req),
vars,
otherArgs,
session: req.sasjsSession,
isStp
session: req.sasjsSession
}
)

Expand Down

0 comments on commit 9aaffce

Please sign in to comment.