Skip to content

Commit a68216d

Browse files
author
David Staheli
authored
Merge pull request #2838 from Microsoft/users/dastahel/af105
Port recent ArchiveFiles fix to releases/m105
2 parents b1c6722 + 8392332 commit a68216d

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Tasks/ArchiveFiles/archivefiles.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,20 @@ function makeAbsolute(normalizedPath: string): string {
5959
}
6060

6161
function getOptions() {
62+
var dirName: string;
6263
if (includeRootFolder) {
63-
tl.debug("cwd (include root folder)= " + path.dirname(rootFolder));
64-
return { cwd: path.dirname(rootFolder) };
64+
dirName = path.dirname(rootFolder);
65+
tl.debug("cwd (include root folder)= " + dirName);
66+
return { cwd: dirName };
6567
} else {
66-
tl.debug("cwd (exclude root folder)= " + rootFolder);
67-
return { cwd: rootFolder };
68+
var stats: tl.FsStats = tl.stats(rootFolder);
69+
if (stats.isFile()) {
70+
dirName = path.dirname(rootFolder);
71+
} else {
72+
dirName = rootFolder;
73+
}
74+
tl.debug("cwd (exclude root folder)= " + dirName);
75+
return { cwd: dirName };
6876
}
6977
}
7078

@@ -260,8 +268,8 @@ function doWork() {
260268
if (tl.exist(archiveFile)) {
261269
if (replaceExistingArchive) {
262270
try {
263-
var stats = tl.stats(archiveFile);
264-
if (stats.isFile) {
271+
var stats: tl.FsStats = tl.stats(archiveFile);
272+
if (stats.isFile()) {
265273
console.log('removing existing archive file before creation: ' + archiveFile);
266274
} else {
267275
failTask('Specified archive file: ' + archiveFile + ' already exists and is not a file.');

0 commit comments

Comments
 (0)