forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist-packages
executable file
·36 lines (31 loc) · 1018 Bytes
/
list-packages
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env node
/**
* Collects all packages in the repository in a way that makes it
* easy to process for packaging.
*/
const child_process = require('child_process');
const fs = require('fs-extra');
const path = require('path');
if (process.argv.length < 4) {
process.stderr.write('Usage: list-packages <jsii file> <nonjsii file>\n');
process.exit(1);
}
child_process.exec('lerna ls --toposort --json', { shell: true }, (error, stdout) => {
if (error) {
console.error('Error: ', error);
process.exit(-1);
}
const modules = JSON.parse(stdout.toString('utf8'));
const jsiiDirectories = [];
const nonJsiiNames = [];
for (const module of modules) {
const pkgJson = require(path.join(module.location, 'package.json'));
if (pkgJson.jsii) {
jsiiDirectories.push(module.location);
} else {
nonJsiiNames.push(pkgJson.name);
}
}
fs.writeFileSync(process.argv[2], jsiiDirectories.join('\n'));
fs.writeFileSync(process.argv[3], nonJsiiNames.join('\n'));
});