From f3bc0cdda8f873af00eb21e9e03e0eccf22f2bfc Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Fri, 1 Oct 2021 07:00:48 -0500 Subject: [PATCH] start implementing shell command utility --- .../UI/Function-Libraries/ActionSwitch.js | 8 +++-- .../Function-Libraries/LaunchShellCommand.js | 34 +++++++++++++++++++ .../UI/Spaces/Docs-Space/DocsSpace.js | 22 ++---------- 3 files changed, 41 insertions(+), 23 deletions(-) create mode 100644 Projects/Education/UI/Function-Libraries/LaunchShellCommand.js diff --git a/Projects/Education/UI/Function-Libraries/ActionSwitch.js b/Projects/Education/UI/Function-Libraries/ActionSwitch.js index 03bf636ca..ff5c8bc37 100644 --- a/Projects/Education/UI/Function-Libraries/ActionSwitch.js +++ b/Projects/Education/UI/Function-Libraries/ActionSwitch.js @@ -18,9 +18,11 @@ function newEducationActionSwitch() { async function executeAction(action) { switch (action.name) { - case 'Action Name': { - // Example: return UI.projects.foundations.functionLibraries.onFocus.getNodeThatIsOnFocus(action.node) - } + case 'Launch Shell Command': + { + UI.projects.education.functionLibraries.launchshellcommand.launchshellcommand(action.node) + } + break } } } diff --git a/Projects/Education/UI/Function-Libraries/LaunchShellCommand.js b/Projects/Education/UI/Function-Libraries/LaunchShellCommand.js new file mode 100644 index 000000000..fe9e06b7b --- /dev/null +++ b/Projects/Education/UI/Function-Libraries/LaunchShellCommand.js @@ -0,0 +1,34 @@ +const path = require("path"); +const process = require("process"); +const { exec } = require("child_process"); + +function newEducationFunctionLibraryLaunchShellCommand() { + let thisObject = { + launchShellCommand: launchShellCommand + } + + return thisObject + + function launchShellCommand() { + + + let dir = path.join( process.cwd(), "..", "..", "..", "..", ".." ) + let command = "node setup"; + exec( command, + { + cwd: dir + }, + function ( error, stdout ){ + if (error) { + console.log(''); + console.log("There was an error updating dependencies for this branch: "); + console.log(''); + console.log( error ); + return; + } + + console.log(''); + console.log( stdout ); + }); + } +} \ No newline at end of file diff --git a/Projects/Education/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Education/UI/Spaces/Docs-Space/DocsSpace.js index a43d55e62..1e5951e80 100644 --- a/Projects/Education/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Education/UI/Spaces/Docs-Space/DocsSpace.js @@ -244,9 +244,6 @@ function newEducationDocSpace() { UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Switching Branches - Changing Current Branch') } - const path = require("path"); - const process = require("process"); - const { exec } = require("child_process"); function onResponse(err, data) { /* Lets check the result of the call through the http interface */ data = JSON.parse(data) @@ -258,24 +255,9 @@ function newEducationDocSpace() { if (doNotNavigate === true) { return } // Run Node Setup to Update dependencies upon branch switch - let dir = path.join( process.cwd(), "..", "..", "..", "..", ".." ) - let command = "node setup"; - exec( command, - { - cwd: dir - }, - function ( error, stdout ){ - if (error) { - console.log(''); - console.log("There was an error updating dependencies for this branch: "); - console.log(''); - console.log( error ); - return; - } + UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Switching Branches - Current Branch Changed') - console.log(''); - console.log( stdout ); - }); + } else { UI.projects.education.spaces.docsSpace.navigateTo( data.docs.project,