Skip to content

Commit

Permalink
fix(publish): Handle binary diff (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
klarstrup authored Sep 17, 2024
1 parent 3631bc7 commit e4f22a8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@
"@aws-sdk/client-cloudfront": "^3.651.1",
"@aws-sdk/client-s3": "^3.651.1",
"@playwright/browser-chromium": "^1.47.1",
"@types/diff": "^5.2.2",
"@types/jest": "^29.5.13",
"@types/mustache": "^4.2.5",
"@types/nib": "^1.1.2",
"@types/node": "^18.16.12",
"@types/recursive-readdir": "^2.2.4",
"@types/semver": "^7.5.8",
"@types/stylus": "^0.48.43",
"@typescript-eslint/eslint-plugin": "^8.6.0",
"@typescript-eslint/parser": "^8.6.0",
Expand Down
23 changes: 14 additions & 9 deletions publish-npm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,18 @@ const printDiffPackage = (diffObj) =>

async function publish() {
console.clear();
if (DRY_RUN) console.info('Dry run! 🌵');

const gitInd = ora(`Git: Checking working tree`).start();
if (await run('git', ['status', '--porcelain'])) {
gitInd.fail(
'Git: Working tree dirty. Please resolve any changes before publishing.'
);
return;
if (DRY_RUN) {
console.info('Dry run! 🌵');
} else {
const gitInd = ora(`Git: Checking working tree`).start();
if (await run('git', ['status', '--porcelain'])) {
gitInd.fail(
'Git: Working tree dirty. Please resolve any changes before publishing.'
);
return;
}
gitInd.succeed(`Git: Working tree clean`);
}
gitInd.succeed(`Git: Working tree clean`);

const commithash = execSync('git rev-parse --short HEAD', {
encoding: 'utf8'
Expand Down Expand Up @@ -301,6 +303,9 @@ async function publish() {
(memo, diff) => {
if (diff) {
memo.changeCount++;
if (diff.includes('Binary files differ')) {
return memo;
}
const [
{
hunks: [hunk]
Expand Down

0 comments on commit e4f22a8

Please sign in to comment.