mirror of
https://github.com/papeloto/action-zip
synced 2024-11-22 05:29:35 -08:00
feat: add recursive support
This commit is contained in:
parent
ed1eb3211d
commit
6842a4f571
2 changed files with 10 additions and 14 deletions
12
dist/index.js
vendored
12
dist/index.js
vendored
|
@ -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}`);
|
||||||
|
|
12
index.js
12
index.js
|
@ -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}`);
|
||||||
|
|
Loading…
Reference in a new issue