azure-pipelines-task-lib 4.17.0 → 4.17.2
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 +10 -10
- package/mock-answer.d.ts +1 -1
- package/mock-answer.js +2 -2
- package/mock-task.d.ts +1 -0
- package/mock-task.js +1 -1
- package/mock-test.js +3 -3
- package/mock-toolrunner.d.ts +1 -0
- package/mock-toolrunner.js +2 -0
- package/package.json +1 -1
- package/task.d.ts +1 -0
- package/task.js +182 -181
- package/toolrunner.d.ts +2 -0
- package/toolrunner.js +66 -59
package/toolrunner.d.ts
CHANGED
package/toolrunner.js
CHANGED
|
@@ -7,6 +7,8 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -107,7 +109,7 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
107
109
|
}
|
|
108
110
|
// Windows + verbatim
|
|
109
111
|
else if (options.windowsVerbatimArguments) {
|
|
110
|
-
commandParts.push("\""
|
|
112
|
+
commandParts.push("\"".concat(toolPath, "\""));
|
|
111
113
|
commandParts = commandParts.concat(args);
|
|
112
114
|
}
|
|
113
115
|
else if (options.shell) {
|
|
@@ -134,23 +136,23 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
134
136
|
}
|
|
135
137
|
return cmd;
|
|
136
138
|
};
|
|
137
|
-
ToolRunner.prototype._processLineBuffer = function (data,
|
|
139
|
+
ToolRunner.prototype._processLineBuffer = function (data, buffer, onLine) {
|
|
140
|
+
var newBuffer = buffer + data.toString();
|
|
138
141
|
try {
|
|
139
|
-
var
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
var line = s.substring(0, n);
|
|
142
|
+
var eolIndex = newBuffer.indexOf(os.EOL);
|
|
143
|
+
while (eolIndex > -1) {
|
|
144
|
+
var line = newBuffer.substring(0, eolIndex);
|
|
143
145
|
onLine(line);
|
|
144
146
|
// the rest of the string ...
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
newBuffer = newBuffer.substring(eolIndex + os.EOL.length);
|
|
148
|
+
eolIndex = newBuffer.indexOf(os.EOL);
|
|
147
149
|
}
|
|
148
|
-
strBuffer = s;
|
|
149
150
|
}
|
|
150
151
|
catch (err) {
|
|
151
152
|
// streaming lines to console is best effort. Don't fail a build.
|
|
152
153
|
this._debug('error processing line');
|
|
153
154
|
}
|
|
155
|
+
return newBuffer;
|
|
154
156
|
};
|
|
155
157
|
/**
|
|
156
158
|
* Wraps an arg string with specified char if it's not already wrapped
|
|
@@ -160,7 +162,7 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
160
162
|
*/
|
|
161
163
|
ToolRunner.prototype._wrapArg = function (arg, wrapChar) {
|
|
162
164
|
if (!this._isWrapped(arg, wrapChar)) {
|
|
163
|
-
return ""
|
|
165
|
+
return "".concat(wrapChar).concat(arg).concat(wrapChar);
|
|
164
166
|
}
|
|
165
167
|
return arg;
|
|
166
168
|
};
|
|
@@ -171,7 +173,7 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
171
173
|
*/
|
|
172
174
|
ToolRunner.prototype._unwrapArg = function (arg, wrapChar) {
|
|
173
175
|
if (this._isWrapped(arg, wrapChar)) {
|
|
174
|
-
var pattern = new RegExp("(^\\\\?"
|
|
176
|
+
var pattern = new RegExp("(^\\\\?".concat(wrapChar, ")|(\\\\?").concat(wrapChar, "$)"), 'g');
|
|
175
177
|
return arg.trim().replace(pattern, '');
|
|
176
178
|
}
|
|
177
179
|
return arg;
|
|
@@ -181,7 +183,7 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
181
183
|
* @param arg Input arg string
|
|
182
184
|
*/
|
|
183
185
|
ToolRunner.prototype._isWrapped = function (arg, wrapChar) {
|
|
184
|
-
var pattern = new RegExp("^\\\\?"
|
|
186
|
+
var pattern = new RegExp("^\\\\?".concat(wrapChar, ".+\\\\?").concat(wrapChar, "$"));
|
|
185
187
|
return pattern.test(arg.trim());
|
|
186
188
|
};
|
|
187
189
|
ToolRunner.prototype._getSpawnFileName = function (options) {
|
|
@@ -199,7 +201,7 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
199
201
|
var _this = this;
|
|
200
202
|
if (process.platform == 'win32') {
|
|
201
203
|
if (this._isCmdFile()) {
|
|
202
|
-
var argline = "/D /S /C \""
|
|
204
|
+
var argline = "/D /S /C \"".concat(this._windowsQuoteCmdArg(this.toolPath));
|
|
203
205
|
for (var i = 0; i < this.args.length; i++) {
|
|
204
206
|
argline += ' ';
|
|
205
207
|
argline += options.windowsVerbatimArguments ? this.args[i] : this._windowsQuoteCmdArg(this.args[i]);
|
|
@@ -243,7 +245,7 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
243
245
|
if (arguments.length != 1) {
|
|
244
246
|
throw new Error('Unexpected arguments passed to args.unshift when windowsVerbatimArguments flag is set.');
|
|
245
247
|
}
|
|
246
|
-
return Array.prototype.unshift.call(args_1, "\""
|
|
248
|
+
return Array.prototype.unshift.call(args_1, "\"".concat(arguments[0], "\"")); // quote the file name
|
|
247
249
|
};
|
|
248
250
|
return args_1;
|
|
249
251
|
}
|
|
@@ -447,7 +449,7 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
447
449
|
if (arg.indexOf('"') < 0 && arg.indexOf('\\') < 0) {
|
|
448
450
|
// No embedded double quotes or backslashes, so I can just wrap
|
|
449
451
|
// quote marks around the whole thing.
|
|
450
|
-
return "\""
|
|
452
|
+
return "\"".concat(arg, "\"");
|
|
451
453
|
}
|
|
452
454
|
// Expected input/output:
|
|
453
455
|
// input : hello"world
|
|
@@ -564,7 +566,7 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
564
566
|
});
|
|
565
567
|
fileStream.on('error', function (err) {
|
|
566
568
|
waitingEvents--; //there were errors writing to the file, write is done
|
|
567
|
-
_this._debug("Failed to pipe output of "
|
|
569
|
+
_this._debug("Failed to pipe output of ".concat(toolPathFirst, " to file ").concat(_this.pipeOutputToFile, ". Error = ").concat(err));
|
|
568
570
|
fileStream = null;
|
|
569
571
|
if (waitingEvents == 0) {
|
|
570
572
|
if (error) {
|
|
@@ -636,17 +638,17 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
636
638
|
}
|
|
637
639
|
}
|
|
638
640
|
});
|
|
639
|
-
var
|
|
641
|
+
var stdLineBuffer = '';
|
|
640
642
|
(_c = cp.stdout) === null || _c === void 0 ? void 0 : _c.on('data', function (data) {
|
|
641
643
|
_this.emit('stdout', data);
|
|
642
644
|
if (!optionsNonNull.silent) {
|
|
643
645
|
optionsNonNull.outStream.write(data);
|
|
644
646
|
}
|
|
645
|
-
_this._processLineBuffer(data,
|
|
647
|
+
stdLineBuffer = _this._processLineBuffer(data, stdLineBuffer, function (line) {
|
|
646
648
|
_this.emit('stdline', line);
|
|
647
649
|
});
|
|
648
650
|
});
|
|
649
|
-
var
|
|
651
|
+
var errLineBuffer = '';
|
|
650
652
|
(_d = cp.stderr) === null || _d === void 0 ? void 0 : _d.on('data', function (data) {
|
|
651
653
|
_this.emit('stderr', data);
|
|
652
654
|
success = !optionsNonNull.failOnStdErr;
|
|
@@ -654,7 +656,7 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
654
656
|
var s = optionsNonNull.failOnStdErr ? optionsNonNull.errStream : optionsNonNull.outStream;
|
|
655
657
|
s.write(data);
|
|
656
658
|
}
|
|
657
|
-
_this._processLineBuffer(data,
|
|
659
|
+
errLineBuffer = _this._processLineBuffer(data, errLineBuffer, function (line) {
|
|
658
660
|
_this.emit('errline', line);
|
|
659
661
|
});
|
|
660
662
|
});
|
|
@@ -669,11 +671,11 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
669
671
|
waitingEvents--; //process is complete
|
|
670
672
|
_this._debug('rc:' + code);
|
|
671
673
|
returnCode = code;
|
|
672
|
-
if (
|
|
673
|
-
_this.emit('stdline',
|
|
674
|
+
if (stdLineBuffer.length > 0) {
|
|
675
|
+
_this.emit('stdline', stdLineBuffer);
|
|
674
676
|
}
|
|
675
|
-
if (
|
|
676
|
-
_this.emit('errline',
|
|
677
|
+
if (errLineBuffer.length > 0) {
|
|
678
|
+
_this.emit('errline', errLineBuffer);
|
|
677
679
|
}
|
|
678
680
|
if (code != 0 && !optionsNonNull.ignoreReturnCode) {
|
|
679
681
|
success = false;
|
|
@@ -744,7 +746,7 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
744
746
|
});
|
|
745
747
|
fileStream.on('error', function (err) {
|
|
746
748
|
waitingEvents--; //there were errors writing to the file, write is done
|
|
747
|
-
_this._debug("Failed to pipe output of "
|
|
749
|
+
_this._debug("Failed to pipe output of ".concat(toolPathFirst, " to file ").concat(_this.pipeOutputToFile, ". Error = ").concat(err));
|
|
748
750
|
fileStream = null;
|
|
749
751
|
if (waitingEvents == 0) {
|
|
750
752
|
if (error) {
|
|
@@ -814,17 +816,17 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
814
816
|
}
|
|
815
817
|
}
|
|
816
818
|
});
|
|
817
|
-
var
|
|
819
|
+
var stdLineBuffer = '';
|
|
818
820
|
(_c = cp.stdout) === null || _c === void 0 ? void 0 : _c.on('data', function (data) {
|
|
819
821
|
_this.emit('stdout', data);
|
|
820
822
|
if (!optionsNonNull.silent) {
|
|
821
823
|
optionsNonNull.outStream.write(data);
|
|
822
824
|
}
|
|
823
|
-
_this._processLineBuffer(data,
|
|
825
|
+
stdLineBuffer = _this._processLineBuffer(data, stdLineBuffer, function (line) {
|
|
824
826
|
_this.emit('stdline', line);
|
|
825
827
|
});
|
|
826
828
|
});
|
|
827
|
-
var
|
|
829
|
+
var errLineBuffer = '';
|
|
828
830
|
(_d = cp.stderr) === null || _d === void 0 ? void 0 : _d.on('data', function (data) {
|
|
829
831
|
_this.emit('stderr', data);
|
|
830
832
|
success = !optionsNonNull.failOnStdErr;
|
|
@@ -832,7 +834,7 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
832
834
|
var s = optionsNonNull.failOnStdErr ? optionsNonNull.errStream : optionsNonNull.outStream;
|
|
833
835
|
s.write(data);
|
|
834
836
|
}
|
|
835
|
-
_this._processLineBuffer(data,
|
|
837
|
+
errLineBuffer = _this._processLineBuffer(data, errLineBuffer, function (line) {
|
|
836
838
|
_this.emit('errline', line);
|
|
837
839
|
});
|
|
838
840
|
});
|
|
@@ -847,11 +849,11 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
847
849
|
waitingEvents--; //process is complete
|
|
848
850
|
_this._debug('rc:' + code);
|
|
849
851
|
returnCode = code;
|
|
850
|
-
if (
|
|
851
|
-
_this.emit('stdline',
|
|
852
|
+
if (stdLineBuffer.length > 0) {
|
|
853
|
+
_this.emit('stdline', stdLineBuffer);
|
|
852
854
|
}
|
|
853
|
-
if (
|
|
854
|
-
_this.emit('errline',
|
|
855
|
+
if (errLineBuffer.length > 0) {
|
|
856
|
+
_this.emit('errline', errLineBuffer);
|
|
855
857
|
}
|
|
856
858
|
if (code != 0 && !optionsNonNull.ignoreReturnCode) {
|
|
857
859
|
success = false;
|
|
@@ -966,16 +968,15 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
966
968
|
state.on('debug', function (message) {
|
|
967
969
|
_this._debug(message);
|
|
968
970
|
});
|
|
969
|
-
var
|
|
970
|
-
var
|
|
971
|
+
var stdLineBuffer = '';
|
|
972
|
+
var errLineBuffer = '';
|
|
971
973
|
var emitDoneEvent = function (resolve, reject) {
|
|
972
|
-
var _this = this;
|
|
973
974
|
state.on('done', function (error, exitCode) {
|
|
974
|
-
if (
|
|
975
|
-
_this.emit('stdline',
|
|
975
|
+
if (stdLineBuffer.length > 0) {
|
|
976
|
+
_this.emit('stdline', stdLineBuffer);
|
|
976
977
|
}
|
|
977
|
-
if (
|
|
978
|
-
_this.emit('errline',
|
|
978
|
+
if (errLineBuffer.length > 0) {
|
|
979
|
+
_this.emit('errline', errLineBuffer);
|
|
979
980
|
}
|
|
980
981
|
if (cp) {
|
|
981
982
|
cp.removeAllListeners();
|
|
@@ -1016,7 +1017,7 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
1016
1017
|
if (!optionsNonNull.silent) {
|
|
1017
1018
|
optionsNonNull.outStream.write(data);
|
|
1018
1019
|
}
|
|
1019
|
-
_this._processLineBuffer(data,
|
|
1020
|
+
stdLineBuffer = _this._processLineBuffer(data, stdLineBuffer, function (line) {
|
|
1020
1021
|
_this.emit('stdline', line);
|
|
1021
1022
|
});
|
|
1022
1023
|
});
|
|
@@ -1027,7 +1028,7 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
1027
1028
|
var s = optionsNonNull.failOnStdErr ? optionsNonNull.errStream : optionsNonNull.outStream;
|
|
1028
1029
|
s.write(data);
|
|
1029
1030
|
}
|
|
1030
|
-
_this._processLineBuffer(data,
|
|
1031
|
+
errLineBuffer = _this._processLineBuffer(data, errLineBuffer, function (line) {
|
|
1031
1032
|
_this.emit('errline', line);
|
|
1032
1033
|
});
|
|
1033
1034
|
});
|
|
@@ -1037,17 +1038,18 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
1037
1038
|
state.processClosed = true;
|
|
1038
1039
|
state.CheckComplete();
|
|
1039
1040
|
});
|
|
1041
|
+
// Do not write debug logs here. Sometimes stdio not closed yet and you can damage user output commands.
|
|
1040
1042
|
cp.on('exit', function (code, signal) {
|
|
1041
1043
|
state.processExitCode = code;
|
|
1044
|
+
state.processExitSignal = signal;
|
|
1042
1045
|
state.processExited = true;
|
|
1043
|
-
_this._debug("STDIO streams have closed and received exit code " + code + " and signal " + signal + " for tool '" + _this.toolPath + "'");
|
|
1044
1046
|
state.CheckComplete();
|
|
1045
1047
|
});
|
|
1046
1048
|
cp.on('close', function (code, signal) {
|
|
1047
|
-
state.
|
|
1048
|
-
state.
|
|
1049
|
+
state.processCloseCode = code;
|
|
1050
|
+
state.processCloseSignal = signal;
|
|
1049
1051
|
state.processClosed = true;
|
|
1050
|
-
|
|
1052
|
+
state.processExited = true;
|
|
1051
1053
|
state.CheckComplete();
|
|
1052
1054
|
});
|
|
1053
1055
|
return new Promise(emitDoneEvent);
|
|
@@ -1082,14 +1084,14 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
1082
1084
|
state.on('debug', function (message) {
|
|
1083
1085
|
_this._debug(message);
|
|
1084
1086
|
});
|
|
1085
|
-
var
|
|
1086
|
-
var
|
|
1087
|
+
var stdLineBuffer = '';
|
|
1088
|
+
var errLineBuffer = '';
|
|
1087
1089
|
state.on('done', function (error, exitCode) {
|
|
1088
|
-
if (
|
|
1089
|
-
_this.emit('stdline',
|
|
1090
|
+
if (stdLineBuffer.length > 0) {
|
|
1091
|
+
_this.emit('stdline', stdLineBuffer);
|
|
1090
1092
|
}
|
|
1091
|
-
if (
|
|
1092
|
-
_this.emit('errline',
|
|
1093
|
+
if (errLineBuffer.length > 0) {
|
|
1094
|
+
_this.emit('errline', errLineBuffer);
|
|
1093
1095
|
}
|
|
1094
1096
|
if (cp) {
|
|
1095
1097
|
cp.removeAllListeners();
|
|
@@ -1127,7 +1129,7 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
1127
1129
|
if (!optionsNonNull.silent) {
|
|
1128
1130
|
optionsNonNull.outStream.write(data);
|
|
1129
1131
|
}
|
|
1130
|
-
_this._processLineBuffer(data,
|
|
1132
|
+
stdLineBuffer = _this._processLineBuffer(data, stdLineBuffer, function (line) {
|
|
1131
1133
|
_this.emit('stdline', line);
|
|
1132
1134
|
});
|
|
1133
1135
|
});
|
|
@@ -1138,7 +1140,7 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
1138
1140
|
var s = optionsNonNull.failOnStdErr ? optionsNonNull.errStream : optionsNonNull.outStream;
|
|
1139
1141
|
s.write(data);
|
|
1140
1142
|
}
|
|
1141
|
-
_this._processLineBuffer(data,
|
|
1143
|
+
errLineBuffer = _this._processLineBuffer(data, errLineBuffer, function (line) {
|
|
1142
1144
|
_this.emit('errline', line);
|
|
1143
1145
|
});
|
|
1144
1146
|
});
|
|
@@ -1148,17 +1150,18 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
1148
1150
|
state.processClosed = true;
|
|
1149
1151
|
state.CheckComplete();
|
|
1150
1152
|
});
|
|
1153
|
+
// Do not write debug logs here. Sometimes stdio not closed yet and you can damage user output commands.
|
|
1151
1154
|
cp.on('exit', function (code, signal) {
|
|
1152
1155
|
state.processExitCode = code;
|
|
1156
|
+
state.processExitSignal = signal;
|
|
1153
1157
|
state.processExited = true;
|
|
1154
|
-
_this._debug("STDIO streams have closed and received exit code " + code + " and signal " + signal + " for tool '" + _this.toolPath + "'");
|
|
1155
1158
|
state.CheckComplete();
|
|
1156
1159
|
});
|
|
1157
1160
|
cp.on('close', function (code, signal) {
|
|
1158
|
-
state.
|
|
1159
|
-
state.
|
|
1161
|
+
state.processCloseCode = code;
|
|
1162
|
+
state.processCloseSignal = signal;
|
|
1160
1163
|
state.processClosed = true;
|
|
1161
|
-
|
|
1164
|
+
state.processExited = true;
|
|
1162
1165
|
state.CheckComplete();
|
|
1163
1166
|
});
|
|
1164
1167
|
return defer.promise;
|
|
@@ -1204,7 +1207,7 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
1204
1207
|
ToolRunner.prototype.killChildProcess = function (signal) {
|
|
1205
1208
|
if (signal === void 0) { signal = "SIGTERM"; }
|
|
1206
1209
|
if (this.childProcess) {
|
|
1207
|
-
this._debug("[killChildProcess] Signal "
|
|
1210
|
+
this._debug("[killChildProcess] Signal ".concat(signal, " received"));
|
|
1208
1211
|
this.childProcess.kill(signal);
|
|
1209
1212
|
}
|
|
1210
1213
|
};
|
|
@@ -1246,6 +1249,7 @@ var ExecState = /** @class */ (function (_super) {
|
|
|
1246
1249
|
// determine whether there is an error
|
|
1247
1250
|
var error;
|
|
1248
1251
|
if (this.processExited) {
|
|
1252
|
+
this._debug("Process exited with code ".concat(this.processExitCode, " and signal ").concat(this.processExitSignal, " for tool '").concat(this.toolPath, "'"));
|
|
1249
1253
|
if (this.processError) {
|
|
1250
1254
|
error = new Error(im._loc('LIB_ProcessError', this.toolPath, this.processError));
|
|
1251
1255
|
}
|
|
@@ -1256,6 +1260,9 @@ var ExecState = /** @class */ (function (_super) {
|
|
|
1256
1260
|
error = new Error(im._loc('LIB_ProcessStderr', this.toolPath));
|
|
1257
1261
|
}
|
|
1258
1262
|
}
|
|
1263
|
+
if (this.processClosed) {
|
|
1264
|
+
this._debug("STDIO streams have closed and received exit code ".concat(this.processCloseCode, " and signal ").concat(this.processCloseSignal, " for tool '").concat(this.toolPath, "'"));
|
|
1265
|
+
}
|
|
1259
1266
|
// clear the timeout
|
|
1260
1267
|
if (this.timeout) {
|
|
1261
1268
|
clearTimeout(this.timeout);
|