15
15
* limitations under the License.
16
16
*/
17
17
18
- import { resolve , basename } from 'path' ;
18
+ import { resolve , basename , dirname } from 'path' ;
19
19
import {
20
20
generateReport ,
21
21
generateReportForModules ,
@@ -24,10 +24,10 @@ import {
24
24
ErrorCode ,
25
25
writeReportToDirectory
26
26
} from './analysis-helper' ;
27
- import { mapWorkspaceToPackages } from '../../scripts/release/utils/workspace' ;
28
- import { projectRoot } from '../../scripts/utils' ;
27
+ import glob from 'glob' ;
29
28
import * as fs from 'fs' ;
30
29
30
+ const projectRoot = dirname ( resolve ( __dirname , '../package.json' ) ) ;
31
31
/**
32
32
* Support Command Line Options
33
33
* -- inputModule (optional) : can be left unspecified which results in running analysis on all exp modules.
@@ -112,3 +112,17 @@ export async function analyzePackageSize(
112
112
throw new Error ( ErrorCode . INVALID_FLAG_COMBINATION ) ;
113
113
}
114
114
}
115
+
116
+ function mapWorkspaceToPackages ( workspaces : string [ ] ) : Promise < string [ ] > {
117
+ return Promise . all < string [ ] > (
118
+ workspaces . map (
119
+ workspace =>
120
+ new Promise ( resolve => {
121
+ glob ( workspace , ( err , paths ) => {
122
+ if ( err ) throw err ;
123
+ resolve ( paths ) ;
124
+ } ) ;
125
+ } )
126
+ )
127
+ ) . then ( paths => paths . reduce ( ( arr , val ) => arr . concat ( val ) , [ ] ) ) ;
128
+ }
0 commit comments