azure-pipelines-tasks-webdeployment-common 4.252.0 → 4.253.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.
@@ -154,14 +154,18 @@ function enhancedFileTransformations(isFolderBasedDeployment, xmlTransformation,
154
154
  }
155
155
  }
156
156
  isSubstitutionApplied = true;
157
+ let InputErrors = tl.getBoolInput('errorOnInvalidSubstitution', false);
157
158
  if (jsonTargetFiles.length > 0) {
158
159
  isSubstitutionApplied = jsonSubstitutionUtility.jsonVariableSubstitution(folderPath, jsonTargetFiles, true);
159
160
  if (isSubstitutionApplied) {
160
161
  console.log(tl.loc('JSONvariablesubstitutionappliedsuccessfully'));
161
162
  }
162
- else {
163
+ else if (InputErrors) {
163
164
  throw Error(tl.loc('FailedToApplyJSONvariablesubstitutionReason1'));
164
165
  }
166
+ else {
167
+ tl.error(tl.loc('FailedToApplyJSONvariablesubstitutionReason1'));
168
+ }
165
169
  }
166
170
  }
167
171
  exports.enhancedFileTransformations = enhancedFileTransformations;
@@ -167,6 +167,7 @@ exports.stripJsonComments = stripJsonComments;
167
167
  function jsonVariableSubstitution(absolutePath, jsonSubFiles, substituteAllTypes) {
168
168
  var envVarObject = createEnvTree(tl.getVariables());
169
169
  let isSubstitutionApplied = false;
170
+ let emptyFiles = [];
170
171
  for (let jsonSubFile of jsonSubFiles) {
171
172
  console.log(tl.loc('JSONvariableSubstitution', jsonSubFile));
172
173
  var matchFiles = utility.findfiles(path.join(absolutePath, jsonSubFile));
@@ -174,6 +175,7 @@ function jsonVariableSubstitution(absolutePath, jsonSubFiles, substituteAllTypes
174
175
  throw new Error(tl.loc('NOJSONfilematchedwithspecificpattern', jsonSubFile));
175
176
  }
176
177
  for (let file of matchFiles) {
178
+ console.log("Processing file: " + file);
177
179
  var fileBuffer = fs.readFileSync(file);
178
180
  if (fileBuffer.length > 4) {
179
181
  var fileEncodeType = fileEncoding.detectFileEncoding(file, fileBuffer);
@@ -197,8 +199,14 @@ function jsonVariableSubstitution(absolutePath, jsonSubFiles, substituteAllTypes
197
199
  }
198
200
  tl.writeFile(file, (fileEncodeType[1] ? '\uFEFF' : '') + JSON.stringify(jsonObject, null, 4), fileEncodeType[0]);
199
201
  }
202
+ else {
203
+ emptyFiles.push(file);
204
+ }
200
205
  }
201
206
  }
207
+ if (emptyFiles.length > 0) {
208
+ console.log(`The following input files either empty: ${emptyFiles.join(', ')}. No substitution was performed.`);
209
+ }
202
210
  return isSubstitutionApplied;
203
211
  }
204
212
  exports.jsonVariableSubstitution = jsonVariableSubstitution;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azure-pipelines-tasks-webdeployment-common",
3
- "version": "4.252.0",
3
+ "version": "4.253.0",
4
4
  "description": "Common Lib for MSDeploy Utility",
5
5
  "repository": {
6
6
  "type": "git",