-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
executable file
·42 lines (38 loc) · 985 Bytes
/
index.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
#!/usr/bin/env node
const { exec } = require('child_process');
const fs = require('fs');
var datArchives = []
function datShare(dir) {
exec(`cd ${dir} && dat share`, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`${stdout}`);
console.log(`${stderr}`);
});
setTimeout(() => {
exec(`cd ${dir} && dat status`, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`Sharing ${dir} 🎉 `)
console.log(`${stdout}`);
console.log(`${stderr}`);
})
}, 2000)
}
setInterval(() => {
fs.readdir(process.cwd(), (err, files) => {
files.forEach(file => {
if (fs.statSync(file).isDirectory() && !datArchives.includes(file)) {
datArchives.push(file)
datShare(file)
}
})
})
}, 2000)
console.log(``)
console.log(` 🎉 Starting the party 🎉 `)
console.log(``)