feat: add recursive support

This commit is contained in:
papeloto 2020-03-21 14:46:00 +01:00
parent ed1eb3211d
commit 6842a4f571
2 changed files with 10 additions and 14 deletions

12
dist/index.js vendored
View file

@ -60,6 +60,7 @@ const core = __webpack_require__(470);
const files = core.getInput("files"); const files = core.getInput("files");
const dest = core.getInput("dest"); const dest = core.getInput("dest");
const recursive = core.getInput("recursive") === "true";
console.log(`Ready to zip "${files}" into ${dest}`); console.log(`Ready to zip "${files}" into ${dest}`);
@ -76,15 +77,12 @@ 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(`filePath: ${filePath}`);
console.log(`fileName: ${fileName}`);
console.log(`dir: ${dir}`);
console.log(`Is dir: ${stats.isDirectory()}`);
if (stats.isDirectory()) { if (stats.isDirectory()) {
zip.addLocalFolder(filePath, dir === "." ? fileName : dir); const zipDir = dir === "." ? fileName : dir;
zip.addLocalFolder(filePath, !recursive && zipDir);
} else { } else {
zip.addLocalFile(filePath, dir === "." ? "" : dir); const zipDir = dir === "." ? "" : dir;
zip.addLocalFile(filePath, !recursive && zipDir);
} }
console.log(` - ${fileName}`); console.log(` - ${fileName}`);

View file

@ -5,6 +5,7 @@ const core = require("@actions/core");
const files = core.getInput("files"); const files = core.getInput("files");
const dest = core.getInput("dest"); const dest = core.getInput("dest");
const recursive = core.getInput("recursive") === "true";
console.log(`Ready to zip "${files}" into ${dest}`); console.log(`Ready to zip "${files}" into ${dest}`);
@ -21,15 +22,12 @@ 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(`filePath: ${filePath}`);
console.log(`fileName: ${fileName}`);
console.log(`dir: ${dir}`);
console.log(`Is dir: ${stats.isDirectory()}`);
if (stats.isDirectory()) { if (stats.isDirectory()) {
zip.addLocalFolder(filePath, dir === "." ? fileName : dir); const zipDir = dir === "." ? fileName : dir;
zip.addLocalFolder(filePath, !recursive && zipDir);
} else { } else {
zip.addLocalFile(filePath, dir === "." ? "" : dir); const zipDir = dir === "." ? "" : dir;
zip.addLocalFile(filePath, !recursive && zipDir);
} }
console.log(` - ${fileName}`); console.log(` - ${fileName}`);