Skip to content

Commit b9ee271

Browse files
committed
fix mistakes.:
1 parent 32cfe10 commit b9ee271

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

scripts/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

src/__tests__/read-package-version.test.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,24 @@ import path from 'path';
22
import fs from 'fs-extra';
33
import { 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+
58
describe('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
});

0 commit comments

Comments
 (0)