@@ -5,31 +5,21 @@ import type { PackageJson } from 'nx/src/utils/package-json';
55const workspaceRoot = path . join ( __dirname , '../../' ) ;
66const projectsFolder = path . join ( __dirname , '../../../' ) ;
77
8- export const cpNxPluginVersion = readDependencyVersion ( workspaceRoot ) ;
9- export const cpModelVersion = readDependencyVersion (
8+ export const cpNxPluginVersion = loadPackageJson ( workspaceRoot ) . version ;
9+ export const cpModelVersion = loadPackageJson (
1010 path . join ( projectsFolder , 'cli' ) ,
11- ) ;
12- export const cpUtilsVersion = readDependencyVersion (
11+ ) . version ;
12+ export const cpUtilsVersion = loadPackageJson (
1313 path . join ( projectsFolder , 'utils' ) ,
14- ) ;
15- export const cpCliVersion = readDependencyVersion (
14+ ) . version ;
15+ export const cpCliVersion = loadPackageJson (
1616 path . join ( projectsFolder , 'models' ) ,
17- ) ;
17+ ) . version ;
1818
1919/**
20- * Load the package.json file from the given folder path and returns the package version .
21- * If the version is not given of the package.json file does not exist it returns the fallback value.
20+ * Load the package.json file from the given folder path.
21+ * @param folderPath
2222 */
23- function readDependencyVersion (
24- folderPath : string ,
25- fallbackVersion = 'latest' ,
26- ) : string {
27- try {
28- return (
29- readJsonFile < PackageJson > ( path . join ( folderPath , 'package.json' ) )
30- . version ?? fallbackVersion
31- ) ;
32- } catch {
33- return fallbackVersion ;
34- }
23+ function loadPackageJson ( folderPath : string ) : PackageJson {
24+ return readJsonFile < PackageJson > ( path . join ( folderPath , 'package.json' ) ) ;
3525}
0 commit comments