@@ -2,9 +2,12 @@ import * as fs from 'node:fs';
22import { glob } from 'glob' ;
33import * as path from 'node:path' ;
44import * as yaml from 'yaml' ;
5+ import { fileURLToPath } from 'node:url' ;
56
67const excludes = [ 'packages/ide/vscode/package.json' ] ;
78
9+ const _dirname = typeof __dirname !== 'undefined' ? __dirname : path . dirname ( fileURLToPath ( import . meta. url ) ) ;
10+
811function getWorkspacePackageJsonFiles ( workspaceFile : string ) : string [ ] {
912 const workspaceYaml = fs . readFileSync ( workspaceFile , 'utf8' ) ;
1013 const workspace = yaml . parse ( workspaceYaml ) as { packages ?: string [ ] } ;
@@ -23,7 +26,7 @@ function getWorkspacePackageJsonFiles(workspaceFile: string): string[] {
2326 }
2427
2528 // include root package.json
26- files . add ( path . resolve ( __dirname , '../package.json' ) ) ;
29+ files . add ( path . resolve ( _dirname , '../package.json' ) ) ;
2730
2831 const result = Array . from ( files ) . filter ( ( f ) => ! excludes . some ( ( e ) => f . endsWith ( e ) ) ) ;
2932 return result ;
@@ -39,11 +42,11 @@ function incrementVersion(version: string): string {
3942}
4043
4144// find all package.json files in the workspace
42- const workspaceFile = path . resolve ( __dirname , '../pnpm-workspace.yaml' ) ;
45+ const workspaceFile = path . resolve ( _dirname , '../pnpm-workspace.yaml' ) ;
4346const packageFiles = getWorkspacePackageJsonFiles ( workspaceFile ) ;
4447
4548// get version from root package.json
46- const rootPackageJson = path . resolve ( __dirname , '../package.json' ) ;
49+ const rootPackageJson = path . resolve ( _dirname , '../package.json' ) ;
4750const rootPkg = JSON . parse ( fs . readFileSync ( rootPackageJson , 'utf8' ) ) as { version ?: string } ;
4851if ( ! rootPkg . version ) throw new Error ( 'No "version" key found in package.json' ) ;
4952const rootVersion = rootPkg . version ;
0 commit comments