File tree Expand file tree Collapse file tree 3 files changed +33
-4
lines changed
Expand file tree Collapse file tree 3 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import getPackages from 'get-monorepo-packages'
33import path from 'path'
44import fs from 'fs'
55import { exists } from '../utils/exists'
6+ import { yarnWorkspaceRootSync } from '@node-kit/yarn-workspace-root'
67
78export type Config = {
89 isDryRun : boolean
@@ -47,10 +48,18 @@ export const getConfig = async (): Promise<Config> => {
4748 }
4849}
4950
50- const getChangelogPath = ( packageName : string ) : string | undefined => {
51- const result = getPackages ( '.' ) . find ( ( p ) =>
52- p . package . name . includes ( packageName )
53- )
51+ const getRelativeWorkspaceRoot = ( ) : string => {
52+ const root = yarnWorkspaceRootSync ( )
53+ if ( ! root ) {
54+ throw new Error ( 'cannot get workspace root.' )
55+ }
56+ return path . relative ( process . cwd ( ) , root )
57+ }
58+
59+ const packages = getPackages ( getRelativeWorkspaceRoot ( ) )
60+
61+ export const getChangelogPath = ( packageName : string ) : string | undefined => {
62+ const result = packages . find ( ( p ) => p . package . name . includes ( packageName ) )
5463 if ( ! result )
5564 throw new Error ( `could not find package with name: ${ packageName } .` )
5665
Original file line number Diff line number Diff line change 1414 },
1515 "packageManager" : " yarn@3.4.1" ,
1616 "devDependencies" : {
17+ "@node-kit/yarn-workspace-root" : " ^3.2.0" ,
1718 "@types/node" : " ^16" ,
1819 "ts-node" : " ^10.8.0"
1920 }
Original file line number Diff line number Diff line change @@ -2850,6 +2850,7 @@ __metadata:
28502850 version: 0.0.0-use.local
28512851 resolution: "@internal/scripts@workspace:scripts"
28522852 dependencies:
2853+ "@node-kit/yarn-workspace-root": ^3.2.0
28532854 "@types/node": ^16
28542855 ts-node: ^10.8.0
28552856 languageName: unknown
@@ -3607,6 +3608,24 @@ __metadata:
36073608 languageName: node
36083609 linkType: hard
36093610
3611+ "@node-kit/extra.fs@npm:3.2.0":
3612+ version: 3.2.0
3613+ resolution: "@node-kit/extra.fs@npm:3.2.0"
3614+ checksum: 48781d37ddd45f544774c17fccf31e1bfe648a16354cf8b20b28f0315798d977336a50c2a4cbb421fd9016792a0860cb2254e7450885324e7ace08903176b58b
3615+ languageName: node
3616+ linkType: hard
3617+
3618+ "@node-kit/yarn-workspace-root@npm:^3.2.0":
3619+ version: 3.2.0
3620+ resolution: "@node-kit/yarn-workspace-root@npm:3.2.0"
3621+ dependencies:
3622+ "@node-kit/extra.fs": 3.2.0
3623+ find-up: ^5.0.0
3624+ micromatch: ^4.0.5
3625+ checksum: 18eca9649017f1b419a230909c319d57fe26400d3074685bb89946be30b3eb6670594dc7bb20d1a4d83cb4b991acf9818026b214fb879717f5ca0290ed934c3e
3626+ languageName: node
3627+ linkType: hard
3628+
36103629"@nodelib/fs.scandir@npm:2.1.5":
36113630 version: 2.1.5
36123631 resolution: "@nodelib/fs.scandir@npm:2.1.5"
You can’t perform that action at this time.
0 commit comments