-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
fixup.js
52 lines (44 loc) · 1.2 KB
/
fixup.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
50
51
import {
chmodSync,
readdirSync,
copyFileSync,
statSync,
mkdirSync,
} from 'node:fs';
import {join} from 'node:path';
/**
* Set execute permissions for a specified file.
*
* @param path - Path to the file.
*/
function setExecutePermissions(path) {
chmodSync(path, 0o755);
console.log(`Execute permissions set for: ${path}`);
}
/**
* Copy files from source directory to target directory.
*
* @param sourceDir - Source directory path.
* @param targetDir - Target directory path.
*/
function copyFiles(sourceDir, targetDir) {
const items = readdirSync(sourceDir);
for (const item of items) {
const sourceItemPath = join(sourceDir, item);
const targetItemPath = join(targetDir, item);
const itemStat = statSync(sourceItemPath);
if (itemStat.isDirectory()) {
mkdirSync(targetItemPath, {recursive: true});
copyFiles(sourceItemPath, targetItemPath);
} else {
copyFileSync(sourceItemPath, targetItemPath);
// Console.log(
// `File successfully copied from: ${sourceItemPath} to ${targetItemPath}`,
// );
}
}
console.log('Files succesfully coppied.');
}
// Main execution
const binPath = './dist/esm/bin.js';
setExecutePermissions(binPath);