fix: dir path zipping

This commit is contained in:
papeloto 2020-03-21 13:33:59 +01:00
parent 579632f552
commit ed1eb3211d
2 changed files with 8 additions and 8 deletions

8
dist/index.js vendored
View file

@ -76,13 +76,13 @@ files.split(" ").forEach(fileName => {
const dir = path.dirname(fileName); const dir = path.dirname(fileName);
const stats = fs.lstatSync(filePath); const stats = fs.lstatSync(filePath);
console.log(`dir: ${dir}`);
console.log(`Is dir: ${stats.isDirectory()}`);
console.log(`filePath: ${filePath}`); console.log(`filePath: ${filePath}`);
console.log(`fileName: ${fileName}`); console.log(`fileName: ${fileName}`);
console.log(`dir: ${dir}`);
console.log(`Is dir: ${stats.isDirectory()}`);
if (stats.isDirectory()) { if (stats.isDirectory()) {
zip.addLocalFolder(filePath, dir); zip.addLocalFolder(filePath, dir === "." ? fileName : dir);
} else { } else {
zip.addLocalFile(filePath, dir === "." ? "" : dir); zip.addLocalFile(filePath, dir === "." ? "" : dir);
} }
@ -94,7 +94,7 @@ const destPath = path.join(process.env.GITHUB_WORKSPACE, dest);
zip.writeZip(destPath); zip.writeZip(destPath);
console.log(`\nZipped file ${destPath} successfully`); console.log(`\nZipped file ${dest} successfully`);
core.setOutput(destPath); core.setOutput(destPath);

View file

@ -21,13 +21,13 @@ files.split(" ").forEach(fileName => {
const dir = path.dirname(fileName); const dir = path.dirname(fileName);
const stats = fs.lstatSync(filePath); const stats = fs.lstatSync(filePath);
console.log(`dir: ${dir}`);
console.log(`Is dir: ${stats.isDirectory()}`);
console.log(`filePath: ${filePath}`); console.log(`filePath: ${filePath}`);
console.log(`fileName: ${fileName}`); console.log(`fileName: ${fileName}`);
console.log(`dir: ${dir}`);
console.log(`Is dir: ${stats.isDirectory()}`);
if (stats.isDirectory()) { if (stats.isDirectory()) {
zip.addLocalFolder(filePath, dir); zip.addLocalFolder(filePath, dir === "." ? fileName : dir);
} else { } else {
zip.addLocalFile(filePath, dir === "." ? "" : dir); zip.addLocalFile(filePath, dir === "." ? "" : dir);
} }
@ -39,6 +39,6 @@ const destPath = path.join(process.env.GITHUB_WORKSPACE, dest);
zip.writeZip(destPath); zip.writeZip(destPath);
console.log(`\nZipped file ${destPath} successfully`); console.log(`\nZipped file ${dest} successfully`);
core.setOutput(destPath); core.setOutput(destPath);