From 5f3416ecd7e889d120a8a99cf19018b122ebefc0 Mon Sep 17 00:00:00 2001 From: Yury Shkoda Date: Tue, 28 Sep 2021 10:39:54 +0300 Subject: [PATCH] chore(utils): add tmpFolder utils --- src/utils/index.ts | 1 + src/utils/tmpFiles.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/utils/tmpFiles.ts diff --git a/src/utils/index.ts b/src/utils/index.ts index 14def48..8480e1f 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -17,3 +17,4 @@ export * from './fetchLogByChunks' export * from './getValidJson' export * from './parseViyaDebugResponse' export * from './appendExtraResponseAttributes' +export * from './tmpFiles' diff --git a/src/utils/tmpFiles.ts b/src/utils/tmpFiles.ts new file mode 100644 index 0000000..4ddc620 --- /dev/null +++ b/src/utils/tmpFiles.ts @@ -0,0 +1,16 @@ +import * as path from 'path' +import { getRealPath, folderExists, createFolder } from '@sasjs/utils' + +export const getTmpFolderPath = async () => { + const tmpFolderPath = path.join(__dirname, '..', 'tmp') + + if (!(await folderExists(tmpFolderPath))) await createFolder(tmpFolderPath) + + return tmpFolderPath +} + +export const getTmpFilesFolderPath = async () => + path.join(await getTmpFolderPath(), 'files') + +export const getTmpLogFolderPath = async () => + path.join(await getTmpFolderPath(), 'log')