-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathsetup-git-hooks.js
36 lines (30 loc) · 1.19 KB
/
setup-git-hooks.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
const fs = require('fs');
const path = require('path');
const sourceFolder = './.github/hooks'; // Replace with the path to your source folder
const destinationFolder = './.git/hooks'; // Replace with the path to your destination folder
// Function to copy a file
function copyFile(source, destination) {
fs.copyFile(source, destination, (err) => {
if (err) {
console.error(`Error copying ${source} to ${destination}: ${err}`);
} else {
console.log(`Copied ${source} to ${destination}`);
}
});
}
// Function to copy all files from the source folder to the destination folder
function copyFilesInFolder(sourceFolder, destinationFolder) {
fs.readdir(sourceFolder, (err, files) => {
if (err) {
console.error(`Error reading source folder: ${err}`);
return;
}
files.forEach((file) => {
const sourcePath = path.join(sourceFolder, file);
const destinationPath = path.join(destinationFolder, file);
copyFile(sourcePath, destinationPath);
});
});
}
// Copy files from the source folder to the destination folder
copyFilesInFolder(sourceFolder, destinationFolder);