1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-13 09:00:04 +00:00

feat: add api endpoint for sasjs drive

This commit is contained in:
2021-10-14 18:21:20 +00:00
parent f90dcff7cf
commit 96b5fef302
4 changed files with 44 additions and 6 deletions

View File

@@ -1,3 +1,4 @@
export * from './sas'
export * from './deploy'
export * from './sasjsExecutor'
export * from './sasjsDrive'

View File

@@ -0,0 +1,24 @@
import { fileExists, readFile, createFile } from '@sasjs/utils'
export const sasjsDrive = async (
filePath: string,
action: string,
newFileContent?: string
) => {
let fileContent
const isFileExists = await fileExists(filePath)
if (isFileExists) {
switch (action) {
case 'read':
fileContent = await readFile(filePath)
return fileContent
case 'update':
if (newFileContent) {
await createFile(filePath, newFileContent)
}
break
default:
break
}
}
}

View File

@@ -2,6 +2,6 @@ import dirTree from 'directory-tree'
import path from 'path'
export const sasjsExecutor = () => {
const tree = dirTree(path.join(__dirname, '..'))
const tree = dirTree(path.join(__dirname, '..', '..', 'tmp'))
return tree
}