Skip to content

Commit

Permalink
Added deprecated runner validation (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
ismayilov-ismayil authored Feb 21, 2023
1 parent f40ae9c commit 2048b21
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/lib/jsonvalidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ var fs = require("fs");
var check = require("validator");
var trace = require("./trace");

const deprecatedRunners = ["Node6"];

/*
* Checks a json file for correct formatting against some validation function
* @param jsonFilePath path to the json file being validated
Expand Down Expand Up @@ -36,6 +38,7 @@ export function validate(jsonFilePath: string, jsonMissingErrorMessage?: string)
}

trace.debug("Json is valid.");
validateRunner(taskJson);
deferred.resolve(taskJson);
return <any>deferred.promise;
}
Expand All @@ -50,6 +53,20 @@ export function exists(path: string, errorMessage: string) {
}
}

/*
* Validates a task against deprecated runner
* @param taskData the parsed json file
*/
export function validateRunner(taskData: any) {
if(taskData == undefined || taskData.execution == undefined)
return

const validRunnerCount = Object.keys(taskData.execution).filter(itm=> deprecatedRunners.indexOf(itm) == -1) || 0;
if(validRunnerCount == 0){
trace.warn("Task %s is dependent on a task runner that is end-of-life and will be removed in the future. Authors should review Node upgrade guidance: https://aka.ms/node-runner-guidance.",taskData.name)
}
}

/*
* Validates a parsed json file describing a build task
* @param taskPath the path to the original json file
Expand Down

0 comments on commit 2048b21

Please sign in to comment.