Skip to content

Commit bb9c4a0

Browse files
Hotfix NpmAuhenticateV0 post-job issue Added checks WorkingFile existing (#17583)
1 parent e734c6a commit bb9c4a0

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

Tasks/NpmAuthenticateV0/npmauthcleanup.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ import * as path from 'path';
77
async function run() {
88
tl.setResourcePath(path.join(__dirname, 'task.json'));
99
const npmrcPath = tl.getVariable("SAVE_NPMRC_PATH");
10+
const workingFilePath = tl.getInput(constants.NpmAuthenticateTaskInput.WorkingFile);
1011
let indexFile = npmrcPath && path.join(npmrcPath, 'index.json');
11-
if (indexFile && tl.exist(indexFile)) {
12+
if (indexFile && tl.exist(indexFile) && tl.exist(workingFilePath)) {
1213
let indexFileText = fs.readFileSync(indexFile, 'utf8');
1314
let jsonObject = JSON.parse(indexFileText);
1415
let npmrcIndex = JSON.stringify(jsonObject[tl.getInput(constants.NpmAuthenticateTaskInput.WorkingFile)]);
15-
util.restoreFileWithName(tl.getInput(constants.NpmAuthenticateTaskInput.WorkingFile), npmrcIndex, tl.getVariable("SAVE_NPMRC_PATH"));
16+
util.restoreFileWithName(workingFilePath, npmrcIndex, tl.getVariable("SAVE_NPMRC_PATH"));
1617
console.log(tl.loc("RevertedChangesToNpmrc", tl.getInput(constants.NpmAuthenticateTaskInput.WorkingFile)));
17-
if (fs.readdirSync(tl.getVariable("SAVE_NPMRC_PATH")).length == 1) {
18-
tl.rmRF(tl.getVariable("NPM_AUTHENTICATE_TEMP_DIRECTORY"));
18+
const tempDirectoryPath = tl.getVariable("NPM_AUTHENTICATE_TEMP_DIRECTORY");
19+
if (tl.exist(tempDirectoryPath) && fs.readdirSync(tl.getVariable("SAVE_NPMRC_PATH")).length == 1) {
20+
tl.rmRF(tempDirectoryPath);
1921
}
2022
}
2123
else {

Tasks/NpmAuthenticateV0/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"version": {
1111
"Major": 0,
1212
"Minor": 216,
13-
"Patch": 0
13+
"Patch": 1
1414
},
1515
"runsOn": [
1616
"Agent",

Tasks/NpmAuthenticateV0/task.loc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"version": {
1111
"Major": 0,
1212
"Minor": 216,
13-
"Patch": 0
13+
"Patch": 1
1414
},
1515
"runsOn": [
1616
"Agent",

0 commit comments

Comments
 (0)