Skip to content

Commit b8ea84f

Browse files
committed
make size analysis self contained
1 parent bf45b49 commit b8ea84f

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

repo-scripts/size-analysis/package-analysis.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { resolve, basename } from 'path';
18+
import { resolve, basename, dirname } from 'path';
1919
import {
2020
generateReport,
2121
generateReportForModules,
@@ -24,10 +24,10 @@ import {
2424
ErrorCode,
2525
writeReportToDirectory
2626
} from './analysis-helper';
27-
import { mapWorkspaceToPackages } from '../../scripts/release/utils/workspace';
28-
import { projectRoot } from '../../scripts/utils';
27+
import glob from 'glob';
2928
import * as fs from 'fs';
3029

30+
const projectRoot = dirname(resolve(__dirname, '../package.json'));
3131
/**
3232
* Support Command Line Options
3333
* -- inputModule (optional) : can be left unspecified which results in running analysis on all exp modules.
@@ -112,3 +112,17 @@ export async function analyzePackageSize(
112112
throw new Error(ErrorCode.INVALID_FLAG_COMBINATION);
113113
}
114114
}
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

Comments
 (0)