azure-pipelines-task-lib 4.10.0 → 4.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/internal.js +6 -6
- package/package.json +1 -1
- package/toolrunner.js +68 -38
package/internal.js
CHANGED
|
@@ -20,7 +20,7 @@ var crypto = require("crypto");
|
|
|
20
20
|
* 3) to know the real variable name and not just the formatted env var name.
|
|
21
21
|
*/
|
|
22
22
|
exports._knownVariableMap = {};
|
|
23
|
-
var
|
|
23
|
+
var _commandCorrelationId;
|
|
24
24
|
//-----------------------------------------------------
|
|
25
25
|
// Enums
|
|
26
26
|
//-----------------------------------------------------
|
|
@@ -270,12 +270,12 @@ function _command(command, properties, message) {
|
|
|
270
270
|
exports._command = _command;
|
|
271
271
|
function _warning(message, source) {
|
|
272
272
|
if (source === void 0) { source = IssueSource.TaskInternal; }
|
|
273
|
-
_command('task.issue', { 'type': 'warning', 'source': source, '
|
|
273
|
+
_command('task.issue', { 'type': 'warning', 'source': source, 'correlationId': _commandCorrelationId }, message);
|
|
274
274
|
}
|
|
275
275
|
exports._warning = _warning;
|
|
276
276
|
function _error(message, source) {
|
|
277
277
|
if (source === void 0) { source = IssueSource.TaskInternal; }
|
|
278
|
-
_command('task.issue', { 'type': 'error', 'source': source, '
|
|
278
|
+
_command('task.issue', { 'type': 'error', 'source': source, 'correlationId': _commandCorrelationId }, message);
|
|
279
279
|
}
|
|
280
280
|
exports._error = _error;
|
|
281
281
|
function _debug(message) {
|
|
@@ -664,9 +664,9 @@ function _loadData() {
|
|
|
664
664
|
}
|
|
665
665
|
}
|
|
666
666
|
_debug('loaded ' + loaded);
|
|
667
|
-
var
|
|
668
|
-
delete process.env["
|
|
669
|
-
|
|
667
|
+
var correlationId = process.env["COMMAND_CORRELATION_ID"];
|
|
668
|
+
delete process.env["COMMAND_CORRELATION_ID"];
|
|
669
|
+
_commandCorrelationId = correlationId ? String(correlationId) : "";
|
|
670
670
|
// store public variable metadata
|
|
671
671
|
var names;
|
|
672
672
|
try {
|
package/package.json
CHANGED
package/toolrunner.js
CHANGED
|
@@ -964,7 +964,42 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
964
964
|
state.on('debug', function (message) {
|
|
965
965
|
_this._debug(message);
|
|
966
966
|
});
|
|
967
|
-
var
|
|
967
|
+
var stdbuffer = '';
|
|
968
|
+
var errbuffer = '';
|
|
969
|
+
var emitDoneEvent = function (resolve, reject) {
|
|
970
|
+
var _this = this;
|
|
971
|
+
state.on('done', function (error, exitCode) {
|
|
972
|
+
if (stdbuffer.length > 0) {
|
|
973
|
+
_this.emit('stdline', stdbuffer);
|
|
974
|
+
}
|
|
975
|
+
if (errbuffer.length > 0) {
|
|
976
|
+
_this.emit('errline', errbuffer);
|
|
977
|
+
}
|
|
978
|
+
if (cp) {
|
|
979
|
+
cp.removeAllListeners();
|
|
980
|
+
}
|
|
981
|
+
if (error) {
|
|
982
|
+
reject(error);
|
|
983
|
+
}
|
|
984
|
+
else {
|
|
985
|
+
resolve(exitCode);
|
|
986
|
+
}
|
|
987
|
+
});
|
|
988
|
+
};
|
|
989
|
+
// Edge case when the node itself cant's spawn and emit event
|
|
990
|
+
var cp;
|
|
991
|
+
try {
|
|
992
|
+
cp = child.spawn(this._getSpawnFileName(options), this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(options));
|
|
993
|
+
}
|
|
994
|
+
catch (error) {
|
|
995
|
+
return new Promise(function (resolve, reject) {
|
|
996
|
+
emitDoneEvent(resolve, reject);
|
|
997
|
+
state.processError = error.message;
|
|
998
|
+
state.processExited = true;
|
|
999
|
+
state.processClosed = true;
|
|
1000
|
+
state.CheckComplete();
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
968
1003
|
this.childProcess = cp;
|
|
969
1004
|
// it is possible for the child process to end its last line without a new line.
|
|
970
1005
|
// because stdout is buffered, this causes the last line to not get sent to the parent
|
|
@@ -974,7 +1009,6 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
974
1009
|
optionsNonNull.outStream.write(os.EOL);
|
|
975
1010
|
}
|
|
976
1011
|
});
|
|
977
|
-
var stdbuffer = '';
|
|
978
1012
|
(_b = cp.stdout) === null || _b === void 0 ? void 0 : _b.on('data', function (data) {
|
|
979
1013
|
_this.emit('stdout', data);
|
|
980
1014
|
if (!optionsNonNull.silent) {
|
|
@@ -984,7 +1018,6 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
984
1018
|
_this.emit('stdline', line);
|
|
985
1019
|
});
|
|
986
1020
|
});
|
|
987
|
-
var errbuffer = '';
|
|
988
1021
|
(_c = cp.stderr) === null || _c === void 0 ? void 0 : _c.on('data', function (data) {
|
|
989
1022
|
state.processStderr = true;
|
|
990
1023
|
_this.emit('stderr', data);
|
|
@@ -1015,23 +1048,7 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
1015
1048
|
_this._debug("STDIO streams have closed for tool '" + _this.toolPath + "'");
|
|
1016
1049
|
state.CheckComplete();
|
|
1017
1050
|
});
|
|
1018
|
-
return new Promise(
|
|
1019
|
-
state.on('done', function (error, exitCode) {
|
|
1020
|
-
if (stdbuffer.length > 0) {
|
|
1021
|
-
_this.emit('stdline', stdbuffer);
|
|
1022
|
-
}
|
|
1023
|
-
if (errbuffer.length > 0) {
|
|
1024
|
-
_this.emit('errline', errbuffer);
|
|
1025
|
-
}
|
|
1026
|
-
cp.removeAllListeners();
|
|
1027
|
-
if (error) {
|
|
1028
|
-
reject(error);
|
|
1029
|
-
}
|
|
1030
|
-
else {
|
|
1031
|
-
resolve(exitCode);
|
|
1032
|
-
}
|
|
1033
|
-
});
|
|
1034
|
-
});
|
|
1051
|
+
return new Promise(emitDoneEvent);
|
|
1035
1052
|
};
|
|
1036
1053
|
/**
|
|
1037
1054
|
* Exec a tool.
|
|
@@ -1063,7 +1080,37 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
1063
1080
|
state.on('debug', function (message) {
|
|
1064
1081
|
_this._debug(message);
|
|
1065
1082
|
});
|
|
1066
|
-
var
|
|
1083
|
+
var stdbuffer = '';
|
|
1084
|
+
var errbuffer = '';
|
|
1085
|
+
state.on('done', function (error, exitCode) {
|
|
1086
|
+
if (stdbuffer.length > 0) {
|
|
1087
|
+
_this.emit('stdline', stdbuffer);
|
|
1088
|
+
}
|
|
1089
|
+
if (errbuffer.length > 0) {
|
|
1090
|
+
_this.emit('errline', errbuffer);
|
|
1091
|
+
}
|
|
1092
|
+
if (cp) {
|
|
1093
|
+
cp.removeAllListeners();
|
|
1094
|
+
}
|
|
1095
|
+
if (error) {
|
|
1096
|
+
defer.reject(error);
|
|
1097
|
+
}
|
|
1098
|
+
else {
|
|
1099
|
+
defer.resolve(exitCode);
|
|
1100
|
+
}
|
|
1101
|
+
});
|
|
1102
|
+
// Edge case when the node itself cant's spawn and emit event
|
|
1103
|
+
var cp;
|
|
1104
|
+
try {
|
|
1105
|
+
cp = child.spawn(this._getSpawnFileName(options), this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(options));
|
|
1106
|
+
}
|
|
1107
|
+
catch (error) {
|
|
1108
|
+
state.processError = error.message;
|
|
1109
|
+
state.processExited = true;
|
|
1110
|
+
state.processClosed = true;
|
|
1111
|
+
state.CheckComplete();
|
|
1112
|
+
return defer.promise;
|
|
1113
|
+
}
|
|
1067
1114
|
this.childProcess = cp;
|
|
1068
1115
|
// it is possible for the child process to end its last line without a new line.
|
|
1069
1116
|
// because stdout is buffered, this causes the last line to not get sent to the parent
|
|
@@ -1073,7 +1120,6 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
1073
1120
|
optionsNonNull.outStream.write(os.EOL);
|
|
1074
1121
|
}
|
|
1075
1122
|
});
|
|
1076
|
-
var stdbuffer = '';
|
|
1077
1123
|
(_b = cp.stdout) === null || _b === void 0 ? void 0 : _b.on('data', function (data) {
|
|
1078
1124
|
_this.emit('stdout', data);
|
|
1079
1125
|
if (!optionsNonNull.silent) {
|
|
@@ -1083,7 +1129,6 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
1083
1129
|
_this.emit('stdline', line);
|
|
1084
1130
|
});
|
|
1085
1131
|
});
|
|
1086
|
-
var errbuffer = '';
|
|
1087
1132
|
(_c = cp.stderr) === null || _c === void 0 ? void 0 : _c.on('data', function (data) {
|
|
1088
1133
|
state.processStderr = true;
|
|
1089
1134
|
_this.emit('stderr', data);
|
|
@@ -1114,21 +1159,6 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
1114
1159
|
_this._debug("STDIO streams have closed for tool '" + _this.toolPath + "'");
|
|
1115
1160
|
state.CheckComplete();
|
|
1116
1161
|
});
|
|
1117
|
-
state.on('done', function (error, exitCode) {
|
|
1118
|
-
if (stdbuffer.length > 0) {
|
|
1119
|
-
_this.emit('stdline', stdbuffer);
|
|
1120
|
-
}
|
|
1121
|
-
if (errbuffer.length > 0) {
|
|
1122
|
-
_this.emit('errline', errbuffer);
|
|
1123
|
-
}
|
|
1124
|
-
cp.removeAllListeners();
|
|
1125
|
-
if (error) {
|
|
1126
|
-
defer.reject(error);
|
|
1127
|
-
}
|
|
1128
|
-
else {
|
|
1129
|
-
defer.resolve(exitCode);
|
|
1130
|
-
}
|
|
1131
|
-
});
|
|
1132
1162
|
return defer.promise;
|
|
1133
1163
|
};
|
|
1134
1164
|
/**
|