1
0
mirror of https://github.com/sasjs/server.git synced 2025-12-10 19:34:34 +00:00

Merge pull request #132 from sasjs/fix-drive-path

Fix drive path
This commit is contained in:
Muhammad Saad
2022-04-19 18:56:13 -07:00
committed by GitHub
3 changed files with 10 additions and 11 deletions

View File

@@ -61,6 +61,6 @@ export default setProcessVariables().then(async () => {
app.use(onError)
connectDB()
await connectDB()
return app
})

View File

@@ -2,7 +2,7 @@ import mongoose from 'mongoose'
import { populateClients } from '../routes/api/auth'
import { seedDB } from './seedDB'
export const connectDB = () => {
export const connectDB = async () => {
// NOTE: when exporting app.js as agent for supertest
// we should exclude connecting to the real database
if (process.env.NODE_ENV === 'test') {

View File

@@ -1,5 +1,5 @@
import path from 'path'
import { getRealPath } from '@sasjs/utils'
import { getAbsolutePath, getRealPath } from '@sasjs/utils'
import { configuration } from '../../package.json'
import { getDesktopFields } from '.'
@@ -12,18 +12,17 @@ export const setProcessVariables = async () => {
const { MODE } = process.env
if (MODE?.trim() !== 'server') {
if (MODE?.trim() === 'server') {
const { SAS_PATH, DRIVE_PATH } = process.env
process.sasLoc = SAS_PATH ?? configuration.sasPath
const absPath = getAbsolutePath(DRIVE_PATH ?? 'tmp', process.cwd())
process.driveLoc = getRealPath(absPath)
} else {
const { sasLoc, driveLoc } = await getDesktopFields()
process.sasLoc = sasLoc
process.driveLoc = driveLoc
} else {
const { SAS_PATH, DRIVE_PATH } = process.env
process.sasLoc = SAS_PATH ?? configuration.sasPath
process.driveLoc = getRealPath(
path.join(process.cwd(), DRIVE_PATH ?? 'tmp')
)
}
console.log('sasLoc: ', process.sasLoc)