Skip to content

Commit

Permalink
dist auto zipping
Browse files Browse the repository at this point in the history
  • Loading branch information
NoCymer committed Jul 31, 2023
1 parent 1727421 commit 32d438b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions manifest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
const fs = require('fs');
const archiver = require('archiver');

function zipDir(sourceDir, outPath) {
const ar = archiver('zip', { zlib: { level: 9 }});
const writeStream = fs.createWriteStream(outPath);

return new Promise((resolve, reject) => {
ar
.directory(sourceDir, false)
.on('error', err => reject(err))
.pipe(writeStream)
;

writeStream.on('close', () => resolve());
ar.finalize();
});
}

const args = process.argv;

Expand Down Expand Up @@ -30,6 +47,19 @@ const main = () => {
break;
}
});
if (fs.existsSync("./dist/dist.zip"))
fs.rmSync("./dist/dist.zip");

if (fs.existsSync("./dist.zip"))
fs.rmSync("./dist.zip");

zipDir("./dist", "./dist.zip").then(() => {
fs.copyFileSync("./dist.zip", "./dist/dist.zip");

if (fs.existsSync("./dist.zip"))
fs.rmSync("./dist.zip");

});
}

main();
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@types/node": "^18.15.13",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"archiver": "^5.3.1",
"axios": "^1.1.3",
"babel-jest": "^29.5.0",
"babel-loader": "^8.2.5",
Expand Down

0 comments on commit 32d438b

Please sign in to comment.