-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpull-external-modules.js
More file actions
executable file
·27 lines (24 loc) · 983 Bytes
/
pull-external-modules.js
File metadata and controls
executable file
·27 lines (24 loc) · 983 Bytes
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
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const dirPath = 'external-modules';
// Check if directory exists
if (fs.existsSync(dirPath)) {
const directories = fs.readdirSync(dirPath).filter(file => {
return fs.statSync(path.join(dirPath, file)).isDirectory();
});
directories.forEach(dir => {
console.log(`Pulling latest changes in ${dir}...`);
try {
execSync('git pull origin main', {
cwd: path.join(dirPath, dir), // Set the current working directory to the child folder
stdio: 'inherit' // Inherit the stdio to see the command output in the terminal
});
console.log(`Pulled latest changes in ${dir} successfully!\n`);
} catch (error) {
console.error(`Error pulling changes in ${dir}: ${error.message}`);
}
});
} else {
console.error(`Directory "${dirPath}" does not exist.`);
}