diff --git a/js/diff.js b/js/diff.js index e56f0801a7..74da540b14 100644 --- a/js/diff.js +++ b/js/diff.js @@ -178,25 +178,6 @@ class Diff var beforeUpgradeFileList = upgradeData.beforeUpgradeFiles || []; - var deleteDirRecursively = function (path) { - if (fs.existsSync(path) && fs.lstatSync(path).isDirectory()) { - fs.readdirSync(path).forEach(function (file, index) { - var curPath = path + "/" + file; - - if (fs.lstatSync(curPath).isDirectory()) { - deleteDirRecursively(curPath); - } else { - fs.unlinkSync(curPath); - } - }); - - fs.rmdirSync(path); - } - else if (fs.existsSync(path) && fs.lstatSync(path).isFile()) { - fs.unlinkSync(path); - } - }; - deleteDirRecursively(diffFilePath); deleteDirRecursively(diffBeforeUpgradeFolderPath); deleteDirRecursively(upgradePath); @@ -421,6 +402,8 @@ class Diff } for (var folder of folderList) { + this.deleteGitFolderInVendor(vendorPath + '/' + folder); + if (fs.existsSync(vendorPath + '/'+ folder)) { cp.execSync("mv " + vendorPath + '/'+ folder+" "+ upgradePath + '/vendorFiles/' + folder); } @@ -430,7 +413,8 @@ class Diff resolve(); - }).then(function () { + }.bind(this)) + .then(function () { var zipOutput = fs.createWriteStream(zipPath); var archive = archiver('zip'); @@ -449,7 +433,7 @@ class Diff archive.finalize(); }); - }); + }.bind(this)); }.bind(this)); } @@ -535,8 +519,43 @@ class Diff return previousAllFileList; } + + deleteGitFolderInVendor (dir) { + var folderList = fs.readdirSync(dir, {withFileTypes: true}) + .filter(dirent => dirent.isDirectory()) + .map(dirent => dirent.name); + + folderList.forEach(function (folder) { + var path = dir + '/' + folder; + + var gitPath = path + '/.git'; + + if (fs.existsSync(gitPath)) { + deleteDirRecursively(gitPath); + } + }); + } } +var deleteDirRecursively = function (path) { + if (fs.existsSync(path) && fs.lstatSync(path).isDirectory()) { + fs.readdirSync(path).forEach(function (file, index) { + var curPath = path + "/" + file; + + if (fs.lstatSync(curPath).isDirectory()) { + deleteDirRecursively(curPath); + } else { + fs.unlinkSync(curPath); + } + }); + + fs.rmdirSync(path); + } + else if (fs.existsSync(path) && fs.lstatSync(path).isFile()) { + fs.unlinkSync(path); + } +}; + function execute (command, callback) { exec(command, function (error, stdout, stderr) { callback(stdout);