diff --git a/dist/index.js b/dist/index.js index 1b2ab6d..9dff2d2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -60,6 +60,7 @@ const core = __webpack_require__(470); const files = core.getInput("files"); const dest = core.getInput("dest"); +const recursive = core.getInput("recursive") === "true"; console.log(`Ready to zip "${files}" into ${dest}`); @@ -76,15 +77,12 @@ files.split(" ").forEach(fileName => { const dir = path.dirname(fileName); 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()) { - zip.addLocalFolder(filePath, dir === "." ? fileName : dir); + const zipDir = dir === "." ? fileName : dir; + zip.addLocalFolder(filePath, !recursive && zipDir); } else { - zip.addLocalFile(filePath, dir === "." ? "" : dir); + const zipDir = dir === "." ? "" : dir; + zip.addLocalFile(filePath, !recursive && zipDir); } console.log(` - ${fileName}`); diff --git a/index.js b/index.js index 17768ef..2de54ca 100644 --- a/index.js +++ b/index.js @@ -5,6 +5,7 @@ const core = require("@actions/core"); const files = core.getInput("files"); const dest = core.getInput("dest"); +const recursive = core.getInput("recursive") === "true"; console.log(`Ready to zip "${files}" into ${dest}`); @@ -21,15 +22,12 @@ files.split(" ").forEach(fileName => { const dir = path.dirname(fileName); 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()) { - zip.addLocalFolder(filePath, dir === "." ? fileName : dir); + const zipDir = dir === "." ? fileName : dir; + zip.addLocalFolder(filePath, !recursive && zipDir); } else { - zip.addLocalFile(filePath, dir === "." ? "" : dir); + const zipDir = dir === "." ? "" : dir; + zip.addLocalFile(filePath, !recursive && zipDir); } console.log(` - ${fileName}`);