Projectpath error message (#274)

* Improve error message

* Improve error message
pull/275/head
David Finol 2021-07-01 06:38:44 -05:00 committed by GitHub
parent 2fc01a1db4
commit b66dffbf92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 10 deletions

18
dist/index.js generated vendored
View File

@ -2104,7 +2104,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__webpack_require__(42186));
const fs = __importStar(__webpack_require__(35747));
const path_1 = __importDefault(__webpack_require__(85622));
class UnityVersioning {
@ -2120,8 +2119,7 @@ class UnityVersioning {
static read(projectPath) {
const filePath = path_1.default.join(projectPath, 'ProjectSettings', 'ProjectVersion.txt');
if (!fs.existsSync(filePath)) {
core.warning(`Could not find "${filePath}", keeping unityVersion as "auto"`);
return 'auto';
throw new Error(`Project settings file not found at "${filePath}". Have you correctly set the projectPath?`);
}
return UnityVersioning.parse(fs.readFileSync(filePath, 'utf8'));
}
@ -190255,7 +190253,7 @@ class WebSocketServer extends EventEmitter {
var protocol = req.headers['sec-websocket-protocol'];
if (protocol) {
protocol = protocol.trim().split(/ *, */);
protocol = protocol.split(',').map(trim);
//
// Optionally call external protocol selection handler.
@ -190375,6 +190373,18 @@ function abortHandshake(socket, code, message, headers) {
socket.destroy();
}
/**
* Remove whitespace characters from both ends of a string.
*
* @param {String} str The string
* @return {String} A new string representing `str` stripped of whitespace
* characters from both its beginning and end
* @private
*/
function trim(str) {
return str.trim();
}
/***/ }),

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -14,8 +14,8 @@ describe('Unity Versioning', () => {
});
describe('read', () => {
it('does not throw', () => {
expect(() => UnityVersioning.read('')).not.toThrow();
it('throws for invalid path', () => {
expect(() => UnityVersioning.read('')).toThrow(Error);
});
it('reads from test-project', () => {

View File

@ -1,4 +1,3 @@
import * as core from '@actions/core';
import * as fs from 'fs';
import path from 'path';
@ -17,8 +16,7 @@ export default class UnityVersioning {
static read(projectPath) {
const filePath = path.join(projectPath, 'ProjectSettings', 'ProjectVersion.txt');
if (!fs.existsSync(filePath)) {
core.warning(`Could not find "${filePath}", keeping unityVersion as "auto"`);
return 'auto';
throw new Error(`Project settings file not found at "${filePath}". Have you correctly set the projectPath?`);
}
return UnityVersioning.parse(fs.readFileSync(filePath, 'utf8'));
}