Skip to content

Commit 02dada4

Browse files
authored
Merge pull request #9 from MattBodily/master
Update to obscure secret variables from console log.
2 parents fb0a1af + 7fa51e0 commit 02dada4

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

Common/Node/expandJObject.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import tl = require('vsts-task-lib/task');
22
export function recursiveProcessing(obj: any, prefix: string, isSecret: boolean): void {
3+
var typeArray: string[] =["string", "number", "boolean"];
34
if (obj instanceof Array) {
45
for (var index = 0; index < obj.length; index++) {
56
var element = obj[index];
67
recursiveProcessing(element, prefix + "_" + index.toString(), isSecret);
78
}
8-
} else if (typeof obj === "string") {
9-
console.log("Injecting variable : " + prefix + ", value : " + obj);
10-
tl.setVariable(prefix, obj, isSecret);
11-
} else if (typeof obj === "number" || typeof obj === "boolean") {
12-
console.log("Injecting variable : " + prefix + ", value : " + obj.toString());
13-
tl.setVariable(prefix, obj.toString(), isSecret);
9+
} else if (typeArray.indexOf(typeof obj) > -1) {
10+
var objValue = typeArray.indexOf(typeof obj)>0 ? obj.toString() : obj;
11+
var objDisplayValue = isSecret ? "******" : objValue;
12+
console.log("Injecting variable : " + prefix + ", value : " + objDisplayValue);
13+
tl.setVariable(prefix, objValue, isSecret);
1414
} else {
1515
for (var key in obj) {
1616
if (obj.hasOwnProperty(key)) {

0 commit comments

Comments
 (0)