Skip to content

Commit

Permalink
Merge pull request #19 from kairi003/feature-build-for-branch
Browse files Browse the repository at this point in the history
Update: create branch-name zip file
  • Loading branch information
kairi003 authored Apr 4, 2023
2 parents 4b0e41c + e024707 commit 95e5769
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,35 @@ const fs = require('fs');
const process = require('process');
const path = require('path');
const archiver = require('archiver');
const { exec } = require('child_process');

const zipPath = `src.zip`;
const output = fs.createWriteStream(path.join(__dirname, zipPath));

process.chdir(path.join(__dirname, 'src'));

const archive = archiver('zip', {
zlib: { level: 9 }
const getBranch = () => new Promise((resolve, reject) => {
exec('git rev-parse --abbrev-ref HEAD', (err, stdout, stderr) => {
if (typeof stdout === 'string') {
resolve(stdout.trim());
} else {
reject(TypeError);
}
});
});

archive.pipe(output);
archive.glob('**/*');

archive.finalize();
const build = async (name) => {
const zipPath = `${name}.zip`;
const output = fs.createWriteStream(path.join(__dirname, zipPath));

process.chdir(path.join(__dirname, 'src'));

const archive = archiver('zip', {
zlib: { level: 9 }
});

archive.pipe(output);
archive.glob('**/*');

await archive.finalize();
}


getBranch().then(build);

0 comments on commit 95e5769

Please sign in to comment.