Improve error message (#132)

pull/134/head
David Finol 2021-07-01 06:39:05 -05:00 committed by GitHub
parent cf55f1c921
commit 6838fda7a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,7 @@
import Input from './input'; import Input from './input';
jest.mock('./unity-version-parser');
describe('Input', () => { describe('Input', () => {
describe('getFromUser', () => { describe('getFromUser', () => {
it('does not throw', () => { it('does not throw', () => {

View File

@ -17,7 +17,9 @@ class UnityVersionParser {
static read(projectPath) { static read(projectPath) {
const filePath = path.join(projectPath, 'ProjectSettings', 'ProjectVersion.txt'); const filePath = path.join(projectPath, 'ProjectSettings', 'ProjectVersion.txt');
if (!fs.existsSync(filePath)) { if (!fs.existsSync(filePath)) {
return 'auto'; throw new Error(
`Project settings file not found at "${filePath}". Have you correctly set the projectPath?`,
);
} }
return UnityVersionParser.parse(fs.readFileSync(filePath, 'utf8')); return UnityVersionParser.parse(fs.readFileSync(filePath, 'utf8'));
} }

View File

@ -14,8 +14,8 @@ describe('UnityVersionParser', () => {
}); });
describe('read', () => { describe('read', () => {
it('does not throw', () => { it('throws for invalid path', () => {
expect(() => UnityVersionParser.read('')).not.toThrow(); expect(() => UnityVersionParser.read('')).toThrow(Error);
}); });
it('reads from unity-project-with-correct-tests', () => { it('reads from unity-project-with-correct-tests', () => {