Skip to content

Commit

Permalink
feat: memory dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
hrenaud committed Jul 19, 2024
1 parent 966a144 commit d941ef2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
9 changes: 8 additions & 1 deletion electron-app/ecoindex-app/src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import {
getWorkDir,
setLogStream,
setMainWindow,
setNodeDir,
setNodeVersion,
setNpmDir,
setWorkDir,
} from '../shared/memory'

Expand Down Expand Up @@ -223,6 +226,7 @@ const _getNodeVersion = async () => {
_debugLogs('ERROR', 'Node dir not found in PATH', _shellEnv)
throw new Error('Node version not found in PATH')
}
setNodeVersion(nodeVersion)
return nodeVersion
}

Expand All @@ -237,6 +241,7 @@ const _getNodeDir = async () => {
throw new Error('Node dir not found in PATH')
}
// console.log(`Node dir: ${nodeDir}`);
setNodeDir(nodeDir)
return nodeDir
}

Expand All @@ -254,7 +259,9 @@ const _getNpmDir = async () => {
// console.log(`Npm dir: ${npmDir}`);
// console.log(`Updated npm dir: ${updatedNpmBinDir}`);

return updatedNpmBinDir + '/lib/node_modules'
const npmDir = updatedNpmBinDir + '/lib/node_modules'
setNpmDir(npmDir)
return npmDir
}

// #endregion
Expand Down
25 changes: 25 additions & 0 deletions electron-app/ecoindex-app/src/shared/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { BrowserWindow } from 'electron'
import fs from 'fs'
import { shellEnv } from 'shell-env'
let workDir = ''
let nodeDir = ''
let npmDir = ''
let nodeVersion = ''
let logStream: fs.WriteStream = null
let mainWindow: BrowserWindow = null
let logStreamPath = ''
Expand All @@ -12,6 +15,28 @@ export const getWorkDir = () => {
export const setWorkDir = (value: string) => {
workDir = value
}

export const getNodeDir = () => {
return nodeDir
}
export const setNodeDir = (value: string) => {
nodeDir = value
}

export const getNpmDir = () => {
return npmDir
}
export const setNpmDir = (value: string) => {
npmDir = value
}

export const getNodeVersion = () => {
return nodeVersion
}
export const setNodeVersion = (value: string) => {
nodeVersion = value
}

export const getHomeDir = async () => {
// fixPath()
const _shellEnv = await shellEnv()
Expand Down

0 comments on commit d941ef2

Please sign in to comment.