-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathex6.js
36 lines (29 loc) · 957 Bytes
/
ex6.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 FolderBuilder = require('../src');
// Create a new FolderBuilder instance with path
const fb = new FolderBuilder(__dirname);
// Create a new folder instance with name
const newFolder = fb.createFolder({
name: 'ex6',
archive: true, // Archiving new folder, it created a zip
});
// Adding a new folder into created folder
const insideFolder = newFolder.addFolder({
name: 'inside',
archive: true, // Archiving the inside folder, it created a zip
});
// Adding a new file into created folder
newFolder.addFile({
name: 'sample.txt',
content: 'sample text ',
});
// Adding a bash file into inside folder which was added into created folder
insideFolder.addFile({
name: 'hello.sh',
content: '#!/bin/bash\necho hello from FolderBuilder',
mode: 0o555, // 555 -> readable and executable
});
// Build a new folder
newFolder.build().catch(console.error);
// So, it will be executed
// ./ex4/inside/hello.sh
// -> hello from FolderBuilder