diff options
author | Minteck <contact@minteck.org> | 2022-02-13 16:48:16 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-02-13 16:48:44 +0100 |
commit | 89ce2aa4b73f21e6bbc060bbfe8438d1baf1a015 (patch) | |
tree | f07b011b94f028571bb7405747c95c259f78295d | |
parent | d2b8ad9963497a557e7ea1dcef436a793c296846 (diff) | |
download | twilight-89ce2aa4b73f21e6bbc060bbfe8438d1baf1a015.tar.gz twilight-89ce2aa4b73f21e6bbc060bbfe8438d1baf1a015.tar.bz2 twilight-89ce2aa4b73f21e6bbc060bbfe8438d1baf1a015.zip |
Fix upgrade not creating directories
-rw-r--r-- | hooks/apply_update.js | 24 |
1 files changed, 24 insertions, 0 deletions
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() !== "") { |