Skip to content

Commit c9fd3a1

Browse files
authored
Moved the link mid-sentence (#482)
This prevents issues when the link is rendered in Azure Pipelines. Fixes: #479
1 parent c9b09b1 commit c9fd3a1

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

app/lib/jsonvalidate.ts

+48-48
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var trace = require("./trace");
55
const deprecatedRunners = ["Node6", "Node10", "Node16"];
66

77
export interface TaskJson {
8-
id: string;
8+
id: string;
99
}
1010

1111
/*
@@ -16,55 +16,55 @@ export interface TaskJson {
1616
* @throws InvalidDirectoryException if json file doesn't exist, InvalidJsonException on failed parse or *first* invalid field in json
1717
*/
1818
export function validate(jsonFilePath: string, jsonMissingErrorMessage?: string): TaskJson {
19-
trace.debug("Validating task json...");
20-
var jsonMissingErrorMsg: string = jsonMissingErrorMessage || "specified json file does not exist.";
21-
this.exists(jsonFilePath, jsonMissingErrorMsg);
19+
trace.debug("Validating task json...");
20+
var jsonMissingErrorMsg: string = jsonMissingErrorMessage || "specified json file does not exist.";
21+
this.exists(jsonFilePath, jsonMissingErrorMsg);
2222

23-
var taskJson;
24-
try {
25-
taskJson = require(jsonFilePath);
26-
} catch (jsonError) {
27-
trace.debug("Invalid task json: %s", jsonError);
28-
throw new Error("Invalid task json: " + jsonError);
29-
}
23+
var taskJson;
24+
try {
25+
taskJson = require(jsonFilePath);
26+
} catch (jsonError) {
27+
trace.debug("Invalid task json: %s", jsonError);
28+
throw new Error("Invalid task json: " + jsonError);
29+
}
3030

31-
var issues: string[] = this.validateTask(jsonFilePath, taskJson);
32-
if (issues.length > 0) {
33-
var output: string = "Invalid task json:";
34-
for (var i = 0; i < issues.length; i++) {
35-
output += "\n\t" + issues[i];
36-
}
37-
trace.debug(output);
38-
throw new Error(output);
39-
}
31+
var issues: string[] = this.validateTask(jsonFilePath, taskJson);
32+
if (issues.length > 0) {
33+
var output: string = "Invalid task json:";
34+
for (var i = 0; i < issues.length; i++) {
35+
output += "\n\t" + issues[i];
36+
}
37+
trace.debug(output);
38+
throw new Error(output);
39+
}
4040

41-
trace.debug("Json is valid.");
42-
validateRunner(taskJson);
43-
return taskJson;
41+
trace.debug("Json is valid.");
42+
validateRunner(taskJson);
43+
return taskJson;
4444
}
4545

4646
/*
4747
* Wrapper for fs.existsSync that includes a user-specified errorMessage in an InvalidDirectoryException
4848
*/
4949
export function exists(path: string, errorMessage: string) {
50-
if (!fs.existsSync(path)) {
51-
trace.debug(errorMessage);
52-
throw new Error(errorMessage);
53-
}
50+
if (!fs.existsSync(path)) {
51+
trace.debug(errorMessage);
52+
throw new Error(errorMessage);
53+
}
5454
}
5555

5656
/*
5757
* Validates a task against deprecated runner
5858
* @param taskData the parsed json file
5959
*/
6060
export function validateRunner(taskData: any) {
61-
if(taskData == undefined || taskData.execution == undefined)
62-
return
61+
if (taskData == undefined || taskData.execution == undefined)
62+
return
6363

64-
const validRunnerCount = Object.keys(taskData.execution).filter(itm=> deprecatedRunners.indexOf(itm) == -1) || 0;
65-
if(validRunnerCount == 0){
66-
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)
67-
}
64+
const validRunnerCount = Object.keys(taskData.execution).filter(itm => deprecatedRunners.indexOf(itm) == -1) || 0;
65+
if (validRunnerCount == 0) {
66+
trace.warn("Task %s is dependent on a task runner that is end-of-life and will be removed in the future. Please visit https://aka.ms/node-runner-guidance to learn how to upgrade the task.", taskData.name)
67+
}
6868
}
6969

7070
/*
@@ -74,23 +74,23 @@ export function validateRunner(taskData: any) {
7474
* @return list of issues with the json file
7575
*/
7676
export function validateTask(taskPath: string, taskData: any): string[] {
77-
var vn = taskData.name || taskPath;
78-
var issues: string[] = [];
77+
var vn = taskData.name || taskPath;
78+
var issues: string[] = [];
7979

80-
if (!taskData.id || !check.isUUID(taskData.id)) {
81-
issues.push(vn + ": id is a required guid");
82-
}
80+
if (!taskData.id || !check.isUUID(taskData.id)) {
81+
issues.push(vn + ": id is a required guid");
82+
}
8383

84-
if (!taskData.name || !check.matches(taskData.name, /^[A-Za-z0-9\-]+$/)) {
85-
issues.push(vn + ": name is a required alphanumeric string");
86-
}
84+
if (!taskData.name || !check.matches(taskData.name, /^[A-Za-z0-9\-]+$/)) {
85+
issues.push(vn + ": name is a required alphanumeric string");
86+
}
8787

88-
if (!taskData.friendlyName || !check.isLength(taskData.friendlyName, 1, 40)) {
89-
issues.push(vn + ": friendlyName is a required string <= 40 chars");
90-
}
88+
if (!taskData.friendlyName || !check.isLength(taskData.friendlyName, 1, 40)) {
89+
issues.push(vn + ": friendlyName is a required string <= 40 chars");
90+
}
9191

92-
if (!taskData.instanceNameFormat) {
93-
issues.push(vn + ": instanceNameFormat is required");
94-
}
95-
return issues;
92+
if (!taskData.instanceNameFormat) {
93+
issues.push(vn + ": instanceNameFormat is required");
94+
}
95+
return issues;
9696
}

0 commit comments

Comments
 (0)