mirror of
https://github.com/sasjs/server.git
synced 2025-12-10 11:24:35 +00:00
35 lines
913 B
TypeScript
35 lines
913 B
TypeScript
import path from 'path'
|
|
import {
|
|
asyncForEach,
|
|
createFile,
|
|
createFolder,
|
|
deleteFolder,
|
|
readFile
|
|
} from '@sasjs/utils'
|
|
|
|
import { getMacrosFolder, sasJSCoreMacros, sasJSCoreMacrosInfo } from '.'
|
|
|
|
export const copySASjsCore = async () => {
|
|
if (process.env.NODE_ENV === 'test') return
|
|
|
|
console.log('Copying Macros from container to drive(tmp).')
|
|
|
|
const macrosDrivePath = getMacrosFolder()
|
|
|
|
await deleteFolder(macrosDrivePath)
|
|
await createFolder(macrosDrivePath)
|
|
|
|
const macros = await readFile(sasJSCoreMacrosInfo)
|
|
|
|
await asyncForEach(macros.split('\n'), async (macroName) => {
|
|
const macroFileSourcePath = path.join(sasJSCoreMacros, macroName)
|
|
const macroContent = await readFile(macroFileSourcePath)
|
|
|
|
const macroFileDestPath = path.join(macrosDrivePath, macroName)
|
|
|
|
await createFile(macroFileDestPath, macroContent)
|
|
})
|
|
|
|
console.log('Macros Drive Path:', macrosDrivePath)
|
|
}
|