mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 11:00:55 +03:00
feat: add driverInfo to mongodb component (#2779)
* feat: add driverInfo to mongodb component NODE-6240 * chore: add a getVersion utility function
This commit is contained in:
@@ -772,3 +772,28 @@ export const prepareSandboxVars = (variables: IVariable[]) => {
|
||||
}
|
||||
return vars
|
||||
}
|
||||
|
||||
let version: string
|
||||
export const getVersion: () => Promise<{ version: string }> = async () => {
|
||||
if (version != null) return { version }
|
||||
|
||||
const checkPaths = [
|
||||
path.join(__dirname, '..', 'package.json'),
|
||||
path.join(__dirname, '..', '..', 'package.json'),
|
||||
path.join(__dirname, '..', '..', '..', 'package.json'),
|
||||
path.join(__dirname, '..', '..', '..', '..', 'package.json'),
|
||||
path.join(__dirname, '..', '..', '..', '..', '..', 'package.json')
|
||||
]
|
||||
for (const checkPath of checkPaths) {
|
||||
try {
|
||||
const content = await fs.promises.readFile(checkPath, 'utf8')
|
||||
const parsedContent = JSON.parse(content)
|
||||
version = parsedContent.version
|
||||
return { version }
|
||||
} catch {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('None of the package.json paths could be parsed')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user