Skip to content

Commit

Permalink
Revert "feat(publish-npm): Skip diffing experimental"
Browse files Browse the repository at this point in the history
This reverts commit e2fa128.
  • Loading branch information
klarstrup committed Sep 9, 2024
1 parent e2fa128 commit 5a7f430
Showing 1 changed file with 36 additions and 41 deletions.
77 changes: 36 additions & 41 deletions publish-npm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -283,50 +283,45 @@ async function publish() {
]
}
]);

if (!tag.startsWith('experimental-')) {
const packageJsonPaths = globSync('./dist/*/package.json');
const packageDiffs = {};
for (const packageJsonPath of packageJsonPaths) {
const pkg = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));
let npmPkg;
try {
npmPkg = await libnpm.manifest(`${pkg.name}@${tag}`);
} catch {}
const diffObj = await npmDiff(packageJsonPath, tag);

packageDiffs[packageJsonPath] = [
npmPkg || {...pkg, version: undefined},
diffObj,
Object.values(diffObj).reduce(
(memo, diff) => {
if (diff) {
memo.changeCount++;
const [
{
hunks: [hunk]
}
] = parsePatch(diff);
if (hunk) {
memo.addCount = memo.addCount + hunk.newLines;
memo.removeCount =
memo.removeCount + hunk.oldLines;
const packageJsonPaths = globSync('./dist/*/package.json');

const packageDiffs = {};
for (const packageJsonPath of packageJsonPaths) {
const pkg = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));
let npmPkg;
try {
npmPkg = await libnpm.manifest(`${pkg.name}@${tag}`);
} catch {}
const diffObj = await npmDiff(packageJsonPath, tag);

packageDiffs[packageJsonPath] = [
npmPkg || {...pkg, version: undefined},
diffObj,
Object.values(diffObj).reduce(
(memo, diff) => {
if (diff) {
memo.changeCount++;
const [
{
hunks: [hunk]
}
] = parsePatch(diff);
if (hunk) {
memo.addCount = memo.addCount + hunk.newLines;
memo.removeCount = memo.removeCount + hunk.oldLines;
}
return memo;
},
{addCount: 0, removeCount: 0, changeCount: 0}
)
];
}
if (
!Object.values(packageDiffs).find(
([, , {changeCount}]) => changeCount
}
return memo;
},
{addCount: 0, removeCount: 0, changeCount: 0}
)
) {
ora().info(`There are no changes to be published`);
process.exit();
}
];
}
if (
!Object.values(packageDiffs).find(([, , {changeCount}]) => changeCount)
) {
ora().info(`There are no changes to be published`);
process.exit();
}

const answers = await inquirer.prompt({
Expand Down

0 comments on commit 5a7f430

Please sign in to comment.