-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunScripts.js
More file actions
60 lines (54 loc) · 1.63 KB
/
runScripts.js
File metadata and controls
60 lines (54 loc) · 1.63 KB
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
50
51
52
53
54
55
56
57
58
59
60
const { execFile } = require('child_process');
const fs = require('fs');
const path = require('path');
// Ensure the output directory exists
const outputDir = path.join(__dirname, 'src', 'generated');
const outputFilePath = path.join(outputDir, 'mindmap.png');
// Function to run Yarn build
function runYarnBuild(callback) {
execFile('yarn', ['build'], (error, stdout, stderr) => {
if (error) {
console.error(`Error running Yarn build: ${error.message}`);
return;
}
if (stderr) {
console.error(`Yarn build stderr: ${stderr}`);
return;
}
console.log(`Yarn build stdout: ${stdout}`);
callback();
});
}
// Function to generate the mind map
function generateMindMap(callback) {
execFile('python', ['generate_mindmap.py'], (error, stdout, stderr) => {
if (error) {
console.error(`Error executing Python script: ${error.message}`);
return;
}
if (stderr) {
console.error(`Python script stderr: ${stderr}`);
return;
}
console.log(`Python script stdout: ${stdout}`);
// Convert the .mmd file to an image using Mermaid CLI
execFile('mmdc', ['-i', 'mindmap.mmd', '-o', outputFilePath], (error, stdout, stderr) => {
if (error) {
console.error(`Error converting .mmd to image: ${error.message}`);
return;
}
if (stderr) {
console.error(`Mermaid CLI stderr: ${stderr}`);
return;
}
console.log(`Mermaid CLI stdout: ${stdout}`);
callback();
});
});
}
// Execute the functions in sequence
runYarnBuild(() => {
generateMindMap(() => {
console.log('Build and mindmap generation complete.');
});
});