@@ -5,12 +5,12 @@ import { globby } from 'globby'
55
66// Temporary forked from nuxt/framework
77
8- async function loadPackage ( dir : string ) {
8+ async function loadPackage ( dir ) {
99 const pkgPath = resolve ( dir , 'package.json' )
1010 const data = JSON . parse ( await fsp . readFile ( pkgPath , 'utf-8' ) . catch ( ( ) => '{}' ) )
1111 const save = ( ) => fsp . writeFile ( pkgPath , JSON . stringify ( data , null , 2 ) + '\n' )
1212
13- const updateDeps = ( reviver : Function ) => {
13+ const updateDeps = ( reviver ) => {
1414 for ( const type of [ 'dependencies' , 'devDependencies' , 'optionalDependencies' , 'peerDependencies' ] ) {
1515 if ( ! data [ type ] ) { continue }
1616 for ( const e of Object . entries ( data [ type ] ) ) {
@@ -31,30 +31,27 @@ async function loadPackage (dir: string) {
3131 }
3232}
3333
34- type ThenArg < T > = T extends PromiseLike < infer U > ? U : T
35- type Package = ThenArg < ReturnType < typeof loadPackage > >
36-
37- async function loadWorkspace ( dir : string ) {
34+ async function loadWorkspace ( dir ) {
3835 const workspacePkg = await loadPackage ( dir )
3936 const pkgDirs = await globby ( workspacePkg . data . workspaces || [ ] , { onlyDirectories : true } )
4037
41- const packages : Package [ ] = [ workspacePkg ]
38+ const packages = [ workspacePkg ]
4239
4340 for ( const pkgDir of pkgDirs ) {
4441 const pkg = await loadPackage ( pkgDir )
4542 if ( ! pkg . data . name ) { continue }
4643 packages . push ( pkg )
4744 }
4845
49- const find = ( name : string ) => {
46+ const find = ( name ) => {
5047 const pkg = packages . find ( pkg => pkg . data . name === name )
5148 if ( ! pkg ) {
5249 throw new Error ( 'Workspace package not found: ' + name )
5350 }
5451 return pkg
5552 }
5653
57- const rename = ( from : string , to : string ) => {
54+ const rename = ( from , to ) => {
5855 find ( from ) . data . name = to
5956 for ( const pkg of packages ) {
6057 pkg . updateDeps ( ( dep ) => {
@@ -65,7 +62,7 @@ async function loadWorkspace (dir: string) {
6562 }
6663 }
6764
68- const setVersion = ( name : string , newVersion : string ) => {
65+ const setVersion = ( name , newVersion ) => {
6966 find ( name ) . data . version = newVersion
7067 for ( const pkg of packages ) {
7168 pkg . updateDeps ( ( dep ) => {
0 commit comments