-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopySASjsCore.ts
36 lines (27 loc) · 1.2 KB
/
copySASjsCore.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import path from 'path'
import { asyncForEach, copy, createFolder, deleteFolder } from '../src'
const root = path.join(__dirname, '..')
const sasjsCorePath = path.join(root, 'node_modules', '@sasjs', 'core')
export const macrosPath = path.join(root, 'build', 'macros')
/**
* We need @sasjs/core macros at runtime for compilation of programs, but we
* can't directly import them like a javascript file.
* So, we have to read the macro files directly. For this we can't use the
* node_modules folder, as it will not always be available after the library is
* built / packed (eg in the VS Code extension)
* Therefore, we copy the macros to a folder in the post build step, so that we
* can read them at runtime.
*
* These macros are / will be used by the sasjs fs command / fs sync utilites
* as well as for general compilation of SAS Jobs, Services, and Tests.
*/
export const copySASjsCore = async () => {
await deleteFolder(macrosPath)
await createFolder(macrosPath)
const foldersToCopy = ['base']
await asyncForEach(foldersToCopy, async (coreSubFolder) => {
const coreSubFolderPath = path.join(sasjsCorePath, coreSubFolder)
await copy(coreSubFolderPath, macrosPath)
})
}
copySASjsCore()