-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-builder.js
49 lines (39 loc) · 1.26 KB
/
example-builder.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
39
40
41
42
43
44
45
46
47
48
49
const fs = require('fs');
const path = require('path');
const { exec } = require("child_process");
const getDirectories = (srcPath) => fs.readdirSync(srcPath)
.filter(file => fs.statSync(path.join(srcPath, file)).isDirectory());
const getFiles = (srcPath) => fs.readdirSync(srcPath)
.filter(file => fs.statSync(path.join(srcPath, file)).isFile());
const getPackageVersion = () => {
let rawData = fs.readFileSync('package.json');
let packageData = JSON.parse(rawData);
return packageData.version;
}
function updateAllExamples() {
const baseDir = './examples';
const rollupConfigFile = 'rollup.config.js';
const version = getPackageVersion();
const folders = getDirectories(baseDir);
for(const folder of folders) {
const path = `${baseDir}/${folder}`;
const files = getFiles(path);
const isExampleFolder = files.includes(rollupConfigFile);
if(isExampleFolder) {
exec(`yarn workspace ${folder} add web-ifc-exporter@${version}`,
(error) => {
if (error) {
console.log(error.message);
}
});
exec(`yarn workspace ${folder} build`,
(error) => {
if (error) {
console.log(error.message);
}
});
}
}
exec(`yarn install`);
}
updateAllExamples();