diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index ff76f75cb..cddb0a04c 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -898,6 +898,27 @@ exports.newHttpInterface = function newHttpInterface() { const git = simpleGit(options) try { await git.checkout(currentBranch) + + // Check to see it main repo has been set as upstream + let remotes = await git.getRemotes(); + let isUpstreamSet + for(let remote in remotes) { + if (remotes[remote].name === 'upstream') { + isUpstreamSet = true + } else { + isUpstreamSet = false + } + } + // If upstream has not been set. Set it now + if (isUpstreamSet === false){ + await git.addRemote('upstream', 'https://github.com/Superalgos/Superalgos'); + } + // Pull branch from main repo + await git.pull('upstream', currentBranch); + // Reset branch to match main repo + let upstreamLocation = `upstream/${currentBranch}` + await git.reset('hard', [upstreamLocation]) + } catch (err) { console.log('[ERROR] Error changing current branch to ' + currentBranch) console.log(err.stack) @@ -905,20 +926,19 @@ exports.newHttpInterface = function newHttpInterface() { } } - async function runNodeSetup() { - console.log("Running Node setup to adjust for new Branch") - const process = require("process"); - const { execSync } = require("child_process"); + async function runNodeSetup () { + console.log( "Running Node setup to adjust for new Branch" ) + const process = SA.nodeModules.process + const childProcess = SA.nodeModules.childProcess let dir = process.cwd() - let command = "node setup"; - let stdout = execSync(command, - { - cwd: dir - }).toString(); - - console.log("Node Setup has completed with the following result:", stdout) - + let command = "node setup noShortcuts"; + let stdout = childProcess.execSync( command, + { + cwd: dir + }).toString(); + + console.log("Node Setup has completed with the following result:", stdout) } } catch (err) { diff --git a/PlatformRoot.js b/PlatformRoot.js index 396a1c727..924c9e1e5 100644 --- a/PlatformRoot.js +++ b/PlatformRoot.js @@ -48,7 +48,9 @@ SA.nodeModules = { ccxt: require('ccxt'), octokit: require("@octokit/rest"), simpleGit: require('simple-git'), - lookpath: require('lookpath') + lookpath: require('lookpath'), + process: require('process'), + childProcess: require('child_process') } run()