mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
🐛 Fix issue that reading version caused problems with build
This commit is contained in:
@@ -1,13 +1,19 @@
|
||||
import * as config from '../config';
|
||||
import * as express from 'express';
|
||||
import { join as pathJoin } from 'path';
|
||||
import {
|
||||
readFile as fsReadFile,
|
||||
} from 'fs';
|
||||
import { promisify } from "util";
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
|
||||
import { IPackageVersions } from './';
|
||||
|
||||
const fsReadFileAsync = promisify(fsReadFile);
|
||||
|
||||
let versionCache: IPackageVersions | undefined;
|
||||
|
||||
|
||||
/**
|
||||
* Displays a message to the user
|
||||
*
|
||||
@@ -54,6 +60,28 @@ export function getSessionId(req: express.Request): string | undefined {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns information which version of the packages are installed
|
||||
*
|
||||
* @export
|
||||
* @returns {Promise<IPackageVersions>}
|
||||
*/
|
||||
export async function getVersions(): Promise<IPackageVersions> {
|
||||
if (versionCache !== undefined) {
|
||||
return versionCache;
|
||||
}
|
||||
|
||||
const packageFile = await fsReadFileAsync(pathJoin(__dirname, '../../package.json'), 'utf8') as string;
|
||||
const packageData = JSON.parse(packageFile);
|
||||
|
||||
versionCache = {
|
||||
cli: packageData.version,
|
||||
};
|
||||
|
||||
return versionCache;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets value from config with support for "_FILE" environment variables
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user