-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-module-descriptors.js
38 lines (34 loc) · 1.31 KB
/
build-module-descriptors.js
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
37
38
const fs = require('fs');
const childProcess = require('child_process');
const argv0 = process.argv[1];
const indir = fs.existsSync('node_modules/@folio') ? 'node_modules/@folio' : '../node_modules/@folio';
const outdir = 'ModuleDescriptors';
let strict = false;
if (process.argv[2] === '--strict') {
strict = true;
}
console.log('* build-module-descriptors');
if (!fs.existsSync(outdir)) {
fs.mkdirSync(outdir);
}
fs.readdir(indir, (err, filenames) => {
if (err) {
console.log(`${argv0}: cannot scan '${err.path}': ${err.message}`);
process.exit(1);
}
const sortedFilenames = filenames.sort();
for (let i = 0; i < sortedFilenames.length; i++) {
const filename = sortedFilenames[i];
if (filename.startsWith('stripes-') && filename !== 'stripes-core' && filename !== 'stripes-smart-components') continue;
console.log(`processing '${filename}'`);
const cmd = `node ${indir}/stripes-core/util/package2md.js${strict ? ' --strict' : ''} ${indir}/${filename}/package.json > ${outdir}/${filename}.json`;
try {
const buffer = childProcess.execSync(cmd);
const output = buffer.toString();
if (output) console.log(`'${cmd}' produced unexpected output: '${output}'`);
} catch (exception) {
console.log(`${argv0}: cannot run '${cmd}':`, exception);
process.exit(2);
}
}
});