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); 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); } } }