Skip to content

Commit 0a98f7f

Browse files
committed
ci(release): Prevent no projects to publish triggering error
1 parent fff378c commit 0a98f7f

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

tools/scripts/release/publish.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import { ProjectGraph } from 'nx/src/config/project-graph';
22
import chalk from 'chalk';
3-
import { colorProjectName } from '../utils/output';
3+
import { colorProjectName, printHeader } from '../utils/output';
44
import { $ } from 'execa';
55
import * as path from 'node:path';
66

77
export function syncPackageJson(projectsList: string[], graph: ProjectGraph) {
8-
console.log(
9-
chalk.bgCyan(chalk.black(' SYNC ')),
10-
`Copy "package.json" files to projects output to sync package version\n`
11-
);
8+
console.log(printHeader('sync', 'cyan'), `Copy "package.json" files to projects output to sync package version\n`);
129
const projects = projectsList.map((projectName) => graph.nodes[projectName]);
1310

1411
const file = 'package.json';

tools/scripts/release/release.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ import { handleChangelog } from './changelog';
113113
return process.exit(0);
114114
} else {
115115
if (projectsList.size === 0) {
116-
console.error(
117-
printHeader('Projects', 'redBright'),
118-
`Trying to publish but no projects were specified. This would release ALL projects with tag '${tag}'! Exiting...`
116+
console.log(
117+
printHeader('Projects', 'yellow'),
118+
`⏭️ Trying to publish but no projects were specified, skipping publish step altogether`
119119
);
120-
return process.exit(1);
120+
return process.exit(0);
121121
}
122122

123123
const projectsListArray = Array.from(projectsList.values());

tools/scripts/utils/output.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chalk, { ColorName } from 'chalk';
1+
import chalk, { ColorName, ForegroundColorName } from 'chalk';
22

33
const colors = [
44
{ instance: chalk.green, spinnerColor: 'green' },
@@ -46,6 +46,6 @@ export async function suppressOutput<T>(fn: () => T): Promise<T> {
4646
return result;
4747
}
4848

49-
export function printHeader(title: string, color: ColorName): string {
50-
return chalk.reset.inverse.bold[color](` ${title.toUpperCase()} `);
49+
export function printHeader(title: string, color: ForegroundColorName): string {
50+
return chalk.reset[color].inverse.bold(` ${title.toUpperCase()} `);
5151
}

0 commit comments

Comments
 (0)