mirror of
https://github.com/sasjs/server.git
synced 2026-01-03 13:10:04 +00:00
feat: compile systemInit and inject to autoExec
This commit is contained in:
35
api/scripts/compileSysInit.ts
Normal file
35
api/scripts/compileSysInit.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import path from 'path'
|
||||
import {
|
||||
createFile,
|
||||
loadDependenciesFile,
|
||||
readFile,
|
||||
SASJsFileType
|
||||
} from '@sasjs/utils'
|
||||
import { apiRoot, sysInitCompiledPath } from '../src/utils'
|
||||
|
||||
const macroCorePath = path.join(apiRoot, 'node_modules', '@sasjs', 'core')
|
||||
|
||||
const compiledSystemInit = async (systemInit: string) =>
|
||||
'options ps=max;\n' +
|
||||
(await loadDependenciesFile({
|
||||
fileContent: systemInit,
|
||||
type: SASJsFileType.job,
|
||||
programFolders: [],
|
||||
macroFolders: [],
|
||||
buildSourceFolder: '',
|
||||
macroCorePath
|
||||
}))
|
||||
|
||||
const createSysInitFile = async () => {
|
||||
console.log('macroCorePath', macroCorePath)
|
||||
const systemInitContent = await readFile(
|
||||
path.join(__dirname, 'systemInit.sas')
|
||||
)
|
||||
|
||||
await createFile(
|
||||
path.join(sysInitCompiledPath),
|
||||
await compiledSystemInit(systemInitContent)
|
||||
)
|
||||
}
|
||||
|
||||
createSysInitFile()
|
||||
15
api/scripts/systemInit.sas
Normal file
15
api/scripts/systemInit.sas
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
@file
|
||||
@brief The systemInit program
|
||||
@details This program is inserted into every sasjs/server program invocation,
|
||||
_before_ any user-provided content.
|
||||
|
||||
<h4> SAS Macros </h4>
|
||||
@li mcf_stpsrv_header.sas
|
||||
|
||||
**/
|
||||
|
||||
|
||||
proc fcmp outcat=work.sasjs.utils;
|
||||
%mcf_stpsrv_header()
|
||||
quit;
|
||||
Reference in New Issue
Block a user