1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-06 22:20:06 +00:00

fix(studio): inject program path to code before sending for execution

This commit is contained in:
2022-09-21 01:57:01 +05:00
parent efd2e1450e
commit edc2e2a302
2 changed files with 34 additions and 2 deletions

View File

@@ -1,3 +1,5 @@
import { RunTimeType } from '../../../context/appContext'
export const getLanguageFromExtension = (extension: string) => {
if (extension === 'js') return 'javascript'
@@ -12,3 +14,26 @@ export const getSelection = (editor: any) => {
const selection = editor?.getModel().getValueInRange(editor?.getSelection())
return selection ?? ''
}
export const programPathInjection = (
code: string,
path: string,
runtime: RunTimeType
) => {
if (path) {
if (runtime === RunTimeType.JS) {
return `const _PROGRAM = '${path}';\n${code}`
}
if (runtime === RunTimeType.PY) {
return `_PROGRAM = '${path}';\n${code}`
}
if (runtime === RunTimeType.R) {
return `._PROGRAM = '${path}';\n${code}`
}
if (runtime === RunTimeType.SAS) {
return `%let _program = '${path}';\n${code}`
}
}
return code
}