Skip to content

Commit

Permalink
Improve publish dry run
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed Aug 19, 2023
1 parent df1e7ed commit 8d7f42d
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions bin/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,24 @@ function checkAndPublishPackage(packageDir) {
const packageJsonFile = path.join(packageDir, 'package.json');
packageJson.version = nextVersion;
console.log(`Set version of ${packageJsonFile} to ${nextVersion}`);
if (!isDryRun) {
fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2));
}
fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2));

// Publish
const args = ['publish'];
if (!isStableRelease) {
args.push('--tag', 'beta');
}
if (isDryRun) {
args.push('--dry-run');
}
console.log(`Spawn: npm ${args.join(' ')}`);
if (!isDryRun) {
const result = cp.spawnSync('npm', args, {
cwd: packageDir,
stdio: 'inherit'
});
if (result.status) {
console.error(`Spawn exited with code ${result.status}`);
process.exit(result.status);
}
const result = cp.spawnSync('npm', args, {
cwd: packageDir,
stdio: 'inherit'
});
if (result.status) {
console.error(`Spawn exited with code ${result.status}`);
process.exit(result.status);
}

console.groupEnd();
Expand Down

0 comments on commit 8d7f42d

Please sign in to comment.