Skip to content

Commit

Permalink
Try to run npm install only if needed !
Browse files Browse the repository at this point in the history
  • Loading branch information
pirquessa committed Feb 8, 2020
1 parent 82cfda9 commit 0190d94
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Vigiupdate",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\vigiupdate.js"
}
]
}
23 changes: 16 additions & 7 deletions utils/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,25 @@ module.exports = {
downloadAndUnzipTag: function(archiveUri, tmpFolder) {
console.log('Download @ ' + archiveUri);

return new Promise(function (resolve, reject) {
return new Promise((resolve, reject) => {
// downloadAndFollowRedirect last archive
this.downloadAndFollowRedirect(archiveUri).then(function (response) {
this.downloadAndFollowRedirect(archiveUri).then((response) => {
response
.pipe(unzipper.Extract({ path: tmpFolder })) // Will create tmpFolder if needed
.on('close', resolve);
.on('close', () => {
try {
fs.readdirSync(tmpFolder).forEach((tmpSubFolder) => { // Zip contain a sub-folder...
this.copyFolder(tmpFolder + path.sep + tmpSubFolder, tmpFolder, []);
this.deleteFileOrFolder(tmpFolder + path.sep + tmpSubFolder);
resolve();
});
}
catch (e) {
reject(e);
}
});
}, reject);
}.bind(this));
});
},

replaceCurrentProject: function(originPath, currentProjetPath) {
Expand All @@ -125,9 +136,7 @@ module.exports = {
}

try {
fs.readdirSync(originPath).forEach(function (projectFolder) { // Zip contain a sub-folder...
this.copyFolder(originPath + path.sep + projectFolder, currentProjetPath, []);
}.bind(this));
this.copyFolder(originPath, currentProjetPath, []);
}
catch (e) {
reject(e);
Expand Down
2 changes: 1 addition & 1 deletion vigiupdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ updateUtils.getLatestTagInfos(repoOwner, repoId).then(function (latestTag) {
}

console.log('Backup current project');
updateUtils.copyFolder(projectFolderPath, backupFolderPath, [path.resolve('update.backup2'), path.resolve('.git'), path.resolve('node_modules'), tempFolderPath, backupFolderPath]);
updateUtils.copyFolder(projectFolderPath, backupFolderPath, [path.resolve('.git'), path.resolve('.vscode'), path.resolve('node_modules'), tempFolderPath, backupFolderPath]);
}
catch(e) {
console.error('Fail to backup current project: ' + e);
Expand Down

0 comments on commit 0190d94

Please sign in to comment.