Skip to content

Commit

Permalink
Merge pull request #18 from manabie-com/feature/custom-only-build-tar…
Browse files Browse the repository at this point in the history
…get-branch-and-show-more-info

update build
  • Loading branch information
phungtruongnguyen94 authored Feb 8, 2022
2 parents 2fc48f7 + ac7c161 commit c0490cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
2 changes: 1 addition & 1 deletion index.js

Large diffs are not rendered by default.

34 changes: 10 additions & 24 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ async function run(octokit, context, token, privateConfig) {
stripHash: stripHash(getInput('strip-hash'))
});

const targetPlugin = new SizePlugin({
compression: getInput('compression'),
pattern: getInput('target-pattern') || '**/dist/**/*.{js,mjs,cjs}',
exclude: getInput('target-exclude') || '{**/*.map,**/node_modules/**}',
stripHash: stripHash(getInput('strip-hash'))
});

const buildScript = getInput('build-script') || 'build';

console.log(`current dir ${process.cwd()}`)
Expand All @@ -66,16 +73,6 @@ async function run(octokit, context, token, privateConfig) {
console.log("new size:")
console.log(newSizes)

const workDir = getInput('cwd')
if (!fs.existsSync(workDir)){
process.chdir(workDir)
console.log(`change dir to ${workDir}`)
} else {
process.chdir(workDir)
console.log(`change dir to ${workDir}`)
}
console.log(`current dir ${process.cwd()}`)

startGroup(`[base] Checkout target branch`);
try {
if (!baseRef) throw Error('missing context.payload.pull_request.base.ref');
Expand Down Expand Up @@ -132,27 +129,16 @@ async function run(octokit, context, token, privateConfig) {
startGroup(`[base] Build using ${npm}`);
await exec(`${npm} run ${buildScript}`);
endGroup();
fs.readdir(process.cwd(), function (err, files) {
//handling error
if (err) {
return console.log('Unable to scan directory: ' + err);
}
//listing all files using forEach
files.forEach(function (file) {
// Do whatever you want to do with the file
console.log(file);
});
});
// In case the build step alters a JSON-file, ....
await exec(`git reset --hard`);
console.log("get old sizes")
const oldSizes = await plugin.readFromDisk(process.cwd());
const oldSizes = await targetPlugin.readFromDisk(process.cwd());
console.log("old sizes:")
console.log(oldSizes)
const diff = await plugin.getDiff(oldSizes, newSizes);
const diff = await targetPlugin.getDiff(oldSizes, newSizes);

startGroup(`Size Differences:`);
const cliText = await plugin.printSizes(diff);
const cliText = await targetPlugin.printSizes(diff);
console.log(cliText);
endGroup();

Expand Down

0 comments on commit c0490cf

Please sign in to comment.