From 89ce2aa4b73f21e6bbc060bbfe8438d1baf1a015 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sun, 13 Feb 2022 16:48:16 +0100 Subject: Fix upgrade not creating directories --- hooks/apply_update.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/hooks/apply_update.js b/hooks/apply_update.js index 8ad9108..6fb23b5 100644 --- a/hooks/apply_update.js +++ b/hooks/apply_update.js @@ -1,4 +1,28 @@ 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(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() !== "") { -- cgit