File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed
Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -237,7 +237,7 @@ main() {
237237 printf ' patternfly-cli --help\n'
238238 printf ' \n'
239239 printf ' If you just installed nvm, open a new terminal or run:\n'
240- printf ' export NVM_DIR="$HOME /.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"\n'
240+ printf ' export NVM_DIR="%s /.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"\n' " ${HOME} "
241241 printf ' \n'
242242}
243243
Original file line number Diff line number Diff line change @@ -2,19 +2,24 @@ import path from 'path';
22import fs from 'fs-extra' ;
33import { readPackageVersion } from '../read-package-version.js' ;
44
5+ /** Repo root package.json (stable under Jest + ts-jest CommonJS emit; avoids cwd brittleness). */
6+ const repoPackageJson = path . join ( __dirname , '../../package.json' ) ;
7+
58describe ( 'readPackageVersion' , ( ) => {
69 it ( 'returns the version from the repo package.json' , ( ) => {
7- const pkgPath = path . join ( process . cwd ( ) , 'package.json' ) ;
8- const pkg = fs . readJsonSync ( pkgPath ) as { version : string } ;
10+ const pkg = fs . readJsonSync ( repoPackageJson ) as { version : string } ;
911
10- expect ( readPackageVersion ( pkgPath ) ) . toBe ( pkg . version ) ;
12+ expect ( readPackageVersion ( repoPackageJson ) ) . toBe ( pkg . version ) ;
1113 expect ( pkg . version . length ) . toBeGreaterThan ( 0 ) ;
1214 } ) ;
1315
1416 it ( "returns 'unknown' when the file does not exist" , ( ) => {
1517 const log = jest . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } ) ;
16- const missing = path . join ( process . cwd ( ) , 'nonexistent-package-xyz.json' ) ;
17- expect ( readPackageVersion ( missing ) ) . toBe ( 'unknown' ) ;
18- log . mockRestore ( ) ;
18+ const missing = path . join ( path . dirname ( repoPackageJson ) , 'nonexistent-package-xyz.json' ) ;
19+ try {
20+ expect ( readPackageVersion ( missing ) ) . toBe ( 'unknown' ) ;
21+ } finally {
22+ log . mockRestore ( ) ;
23+ }
1924 } ) ;
2025} ) ;
You can’t perform that action at this time.
0 commit comments