Skip to content

Commit

Permalink
Fixes a boolean check on the OS Type option (#24)
Browse files Browse the repository at this point in the history
Fixing options bool check for OS Type
  • Loading branch information
ryancole authored and romil07 committed Nov 24, 2020
1 parent 7f33cb7 commit 91a439f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
12 changes: 6 additions & 6 deletions lib/taskparameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class TaskParameters {
this._memory = parseFloat(core.getInput('memory'));
this._containerName = core.getInput('name', { required: true });
let osType = core.getInput('os-type');
if (osType != 'Linux' && 'Windows') {
throw Error('The Value of OS Type must be either Linux or Windows only!');
if (["Linux", "Windows"].includes(osType) == false) {
throw Error(`The Value of OS Type must be either Linux or Windows only - got ${osType}!`);
}
else {
this._osType = (osType == 'Linux') ? 'Linux' : 'Windows';
Expand Down Expand Up @@ -120,8 +120,8 @@ class TaskParameters {
keyValuePairs.forEach((pair) => {
// value is either wrapped in quotes or not
let pairList = pair.split(/=(?:"(.+)"|(.+))/);
let obj = {
"name": pairList[0],
let obj = {
"name": pairList[0],
"value": pairList[1] || pairList[2]
};
this._environmentVariables.push(obj);
Expand All @@ -133,8 +133,8 @@ class TaskParameters {
keyValuePairs.forEach((pair) => {
// value is either wrapped in quotes or not
let pairList = pair.split(/=(?:"(.+)"|(.+))/);
let obj = {
"name": pairList[0],
let obj = {
"name": pairList[0],
"value": pairList[1] || pairList[2]
};
this._environmentVariables.push(obj);
Expand Down
6 changes: 4 additions & 2 deletions src/taskparameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ export class TaskParameters {
this._location = core.getInput('location', { required: true });
this._memory = parseFloat(core.getInput('memory'));
this._containerName = core.getInput('name', { required: true });

let osType = core.getInput('os-type');
if(osType != 'Linux' && 'Windows') {
throw Error('The Value of OS Type must be either Linux or Windows only!')
if (["Linux", "Windows"].includes(osType) == false) {
throw Error(`The Value of OS Type must be either Linux or Windows only - got ${osType}!`);
} else {
this._osType = (osType == 'Linux') ? 'Linux' : 'Windows';
}

let ports = core.getInput('ports');
this._ports = [];
this._getPorts(ports);
Expand Down

0 comments on commit 91a439f

Please sign in to comment.