Skip to content

Commit

Permalink
yarn updates and lint fix in server-side index.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
scholarsmate committed Oct 21, 2024
1 parent 7e26f7c commit ff2e782
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 131 deletions.
20 changes: 11 additions & 9 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import * as path from 'path'
* OR
* - calls the getBinFolderPath going back a directory
*/
const checkForBinPath = (baseDir: string) => {
const checkForBinPath = (baseDir: string): string => {
const serverbasePath = 'node_modules/@omega-edit/server'

// These two are checked as when testing locally it will want to use out/bin
Expand All @@ -46,26 +46,28 @@ const checkForBinPath = (baseDir: string) => {
path.join(baseDir, serverbasePath, 'out', 'bin'),
]

for (let i = 0; i < pathsToCheck.length; i++) {
if (fs.existsSync(pathsToCheck[i])) return path.resolve(pathsToCheck[i])
for (const p of pathsToCheck) {
if (fs.existsSync(p)) return path.resolve(p)
}

return getBinFolderPath(path.join(baseDir, '..'))
}

/**
*
* Recursively finds the bin folder path
* @param baseDir the base path to the directory to check against
* @returns
* - path to bin directory
* OR
* - recursively calls itself till path is found
*/
const getBinFolderPath = (baseDir: string) => {
const getBinFolderPath = (baseDir: string): string => {
if (!baseDir.endsWith('node_modules')) {
if (fs.readdirSync(baseDir).includes('node_modules'))
if (fs.readdirSync(baseDir).includes('node_modules')) {
return checkForBinPath(baseDir)
else return getBinFolderPath(path.join(baseDir, '..'))
} else {
return getBinFolderPath(path.join(baseDir, '..'))
}
} else {
return checkForBinPath(baseDir.replace('node_modules', ''))
}
Expand All @@ -74,7 +76,7 @@ const getBinFolderPath = (baseDir: string) => {
/**
* Execute the server
* @param args arguments to pass to the server
* @returns {ChildProcess} server process
* @returns {Promise<ChildProcess>} server process
*/
async function executeServer(args: string[]): Promise<ChildProcess> {
const serverScript = path.join(
Expand Down Expand Up @@ -108,7 +110,7 @@ async function executeServer(args: string[]): Promise<ChildProcess> {
* @param host hostname or IP address (default: 127.0.0.1)
* @param pidfile resolved path to the PID file
* @param logConf resolved path to a logback configuration file
* @returns {ChildProcess} server process
* @returns {Promise<ChildProcess>} server process
*/
export async function runServer(
port: number,
Expand Down
Loading

0 comments on commit ff2e782

Please sign in to comment.