blob: 3cfcbc56aa57acc5f3b4813d3b96264b7c3a92fd (
plain)
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
|
module.exports = (pkg, tempDir) => {
const getAllDirs = function(dirPath, arrayOfFiles) {
files = fs.readdirSync(dirPath)
arrayOfFiles = arrayOfFiles || []
files.forEach(function(file) {
if (file !== ".git") {
if (fs.statSync(dirPath + "/" + file).isDirectory()) {
arrayOfFiles.push(dirPath + "/" + file)
arrayOfFiles = getAllDirs(dirPath + "/" + file, arrayOfFiles)
}
}
})
return arrayOfFiles
}
dirs = getAllDirs((home + "/packages/" + tempDir).replaceAll("\\", "/")).map(i => i.replaceAll("\\", "/").replaceAll((home + "/packages/" + tempDir).replaceAll("\\", "/") + "/", ""));
for (let dir of dirs) {
if (!fs.existsSync(home + "/packages/" + pkg + "/" + dir)) {
fs.mkdirSync(home + "/packages/" + pkg + "/" + dir);
}
}
files = require('./files')(tempDir);
for (let file of files) {
if (file.trim() !== "") {
fs.copyFileSync(home + "/packages/" + tempDir + "/" + file, home + "/packages/" + pkg + "/" + file);
}
}
}
|