diff --git a/dist/index.js b/dist/index.js index 4d2c0aa..30fc78b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -58,42 +58,42 @@ const path = __webpack_require__(622); const AdmZip = __webpack_require__(639); const core = __webpack_require__(470); -const inputFiles = core.getInput("files", { required: true }); -const filename = core.getInput("output"); - -const files = inputFiles +const files = core + .getInput("files", { required: true }) .split(" ") .map(file => path.join(process.env.GITHUB_WORKSPACE, file)); -console.log(`Ready to zip "${inputFiles}" into ${filename}`); +const output = path.join(process.env.GITHUB_WORKSPACE, core.getInput("output")); + +console.log(`Ready to zip "${files}" into ${output}`); const zip = new AdmZip(); -console.log(files); - files.forEach(file => { - if (!fs.existsSync(file)) { - console.log(` - ${file} (Not Found)`); + const filename = file.replace(process.env.GITHUB_WORKSPACE, ""); + + if (!fs.existsSync(filename)) { + console.log(` - ${filename} (Not Found)`); return; } - const dir = path.dirname(file); - const stats = fs.lstatSync(file); + const dir = path.dirname(filename); + const stats = fs.lstatSync(filename); if (stats.isDirectory()) { - zip.addLocalFolder(file, dir); + zip.addLocalFolder(filename, dir); } else { - zip.addLocalFile(file, dir === "." ? "" : dir); + zip.addLocalFile(filename, dir === "." ? "" : dir); } - console.log(` - ${file}`); + console.log(` - ${filename}`); }); -zip.writeZip(filename); +zip.writeZip(output); -console.log(`\nZipped file ${filename}`); +console.log(`\nZipped file ${output}`); -core.setOutput(filename); +core.setOutput(output); /***/ }), diff --git a/index.js b/index.js index 1167fbb..4ced02c 100644 --- a/index.js +++ b/index.js @@ -3,39 +3,39 @@ const path = require("path"); const AdmZip = require("adm-zip"); const core = require("@actions/core"); -const inputFiles = core.getInput("files", { required: true }); -const filename = core.getInput("output"); - -const files = inputFiles +const files = core + .getInput("files", { required: true }) .split(" ") .map(file => path.join(process.env.GITHUB_WORKSPACE, file)); -console.log(`Ready to zip "${inputFiles}" into ${filename}`); +const output = path.join(process.env.GITHUB_WORKSPACE, core.getInput("output")); + +console.log(`Ready to zip "${files}" into ${output}`); const zip = new AdmZip(); -console.log(files); - files.forEach(file => { - if (!fs.existsSync(file)) { - console.log(` - ${file} (Not Found)`); + const filename = file.replace(process.env.GITHUB_WORKSPACE, ""); + + if (!fs.existsSync(filename)) { + console.log(` - ${filename} (Not Found)`); return; } - const dir = path.dirname(file); - const stats = fs.lstatSync(file); + const dir = path.dirname(filename); + const stats = fs.lstatSync(filename); if (stats.isDirectory()) { - zip.addLocalFolder(file, dir); + zip.addLocalFolder(filename, dir); } else { - zip.addLocalFile(file, dir === "." ? "" : dir); + zip.addLocalFile(filename, dir === "." ? "" : dir); } - console.log(` - ${file}`); + console.log(` - ${filename}`); }); -zip.writeZip(filename); +zip.writeZip(output); -console.log(`\nZipped file ${filename}`); +console.log(`\nZipped file ${output}`); -core.setOutput(filename); +core.setOutput(output);