Improve error message (#132)
parent
cf55f1c921
commit
6838fda7a4
File diff suppressed because one or more lines are too long
|
@ -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', () => {
|
||||||
|
|
|
@ -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'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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', () => {
|
||||||
|
|
Loading…
Reference in New Issue