@@ -7,6 +7,8 @@ import type { VersionBumpOptions } from '../types/version-bump-options'
7
7
import { version } from '../../package.json'
8
8
import { bumpConfigDefaults , loadBumpConfig } from '../config'
9
9
import { ExitCode } from './exit-code'
10
+ import node_fs from 'node:fs'
11
+ import yaml from 'js-yaml'
10
12
11
13
/**
12
14
* The parsed command-line arguments
@@ -79,9 +81,23 @@ export async function parseArgs(): Promise<ParsedArgs> {
79
81
if ( parsedArgs . options . recursive ) {
80
82
if ( parsedArgs . options . files ?. length )
81
83
console . log ( c . yellow ( 'The --recursive option is ignored when files are specified' ) )
82
-
83
- else
84
+ else {
84
85
parsedArgs . options . files = [ 'package.json' , 'package-lock.json' , 'packages/**/package.json' ]
86
+
87
+ // check if pnpm-workspace.yaml exists, if so, add all workspaces to files
88
+ if ( node_fs . existsSync ( 'pnpm-workspace.yaml' ) ) {
89
+ // read pnpm-workspace.yaml
90
+ const pnpmWorkspace = node_fs . readFileSync ( 'pnpm-workspace.yaml' , 'utf8' )
91
+ // parse yaml
92
+ const workspaces = yaml . load ( pnpmWorkspace ) as { packages : string [ ] }
93
+ // append package.json to each workspace string
94
+ const workspacesWithPackageJson = workspaces . packages . map ( ( workspace ) => workspace + '/package.json' )
95
+ // start with ! or already in files should be excluded
96
+ const withoutExcludedWorkspaces = workspacesWithPackageJson . filter ( ( workspace ) => ! workspace . startsWith ( '!' ) && ! parsedArgs . options . files ?. includes ( workspace ) )
97
+ // add to files
98
+ parsedArgs . options . files = parsedArgs . options . files . concat ( withoutExcludedWorkspaces )
99
+ }
100
+ }
85
101
}
86
102
87
103
return parsedArgs
0 commit comments