diff --git a/src/actions/tutorialConfig.ts b/src/actions/tutorialConfig.ts index 9785c6ae..420190ce 100644 --- a/src/actions/tutorialConfig.ts +++ b/src/actions/tutorialConfig.ts @@ -3,6 +3,7 @@ import * as TT from 'typings/tutorial' import * as vscode from 'vscode' import { COMMANDS } from '../editor/commands' import * as git from '../services/git' +import { DISABLE_RUN_ON_SAVE } from '../environment' interface TutorialConfigParams { config: TT.TutorialConfig @@ -53,21 +54,23 @@ const tutorialConfig = async ({ config, alreadyConfigured }: TutorialConfigParam await vscode.commands.executeCommand(COMMANDS.CONFIG_TEST_RUNNER, config.testRunner) - // verify if file test should run based on document saved - const shouldRunTest = (document: vscode.TextDocument): boolean => { - // must be a file - if (document.uri.scheme !== 'file') { - return false + if (!DISABLE_RUN_ON_SAVE) { + // verify if file test should run based on document saved + const shouldRunTest = (document: vscode.TextDocument): boolean => { + // must be a file + if (document.uri.scheme !== 'file') { + return false + } + return true } - return true - } - // setup onSave hook - vscode.workspace.onDidSaveTextDocument((document: vscode.TextDocument) => { - if (shouldRunTest(document)) { - vscode.commands.executeCommand(COMMANDS.RUN_TEST) - } - }) + // setup onSave hook + vscode.workspace.onDidSaveTextDocument((document: vscode.TextDocument) => { + if (shouldRunTest(document)) { + vscode.commands.executeCommand(COMMANDS.RUN_TEST) + } + }) + } } export default tutorialConfig diff --git a/src/channel/index.ts b/src/channel/index.ts index ec38dd62..2c1ffa99 100644 --- a/src/channel/index.ts +++ b/src/channel/index.ts @@ -309,7 +309,6 @@ class Channel implements Channel { // run test following solution to update position vscode.commands.executeCommand(COMMANDS.RUN_TEST) return - case 'EDITOR_SYNC_PROGRESS': // update progress when a level is deemed complete in the client await this.context.progress.syncProgress(action.payload.progress) @@ -317,6 +316,10 @@ class Channel implements Channel { case 'EDITOR_OPEN_LOGS': const channel = action.payload.channel await showOutput(channel) + return + case 'EDITOR_RUN_TEST': + vscode.commands.executeCommand(COMMANDS.RUN_TEST) + return default: logger(`No match for action type: ${actionType}`) return diff --git a/src/environment.ts b/src/environment.ts index 23ff02fb..09111205 100644 --- a/src/environment.ts +++ b/src/environment.ts @@ -35,3 +35,5 @@ if (!supportedOS.includes(OS_PLATFORM)) { } export const TUTORIAL_URL: string | null = process.env.CODEROAD_TUTORIAL_URL || null + +export const DISABLE_RUN_ON_SAVE = (process.env.CODEROAD_DISABLE_RUN_ON_SAVE || '').toLowerCase() === 'true' diff --git a/web-app/src/containers/Tutorial/components/Level.tsx b/web-app/src/containers/Tutorial/components/Level.tsx index 2ee7a26b..de9fc07c 100644 --- a/web-app/src/containers/Tutorial/components/Level.tsx +++ b/web-app/src/containers/Tutorial/components/Level.tsx @@ -9,6 +9,7 @@ import Markdown from '../../../components/Markdown' import ProcessMessages from '../../../components/ProcessMessages' import NuxTutorial from '../../../components/NewUserExperience/NuxTutorial' import Step from './Step' +import { DISPLAY_RUN_TEST_BUTTON } from '../../../environment' const styles = { page: { @@ -95,6 +96,7 @@ interface Props { processes: T.ProcessEvent[] testStatus: T.TestStatus | null onContinue(): void + onRunTest(): void onLoadSolution(): void onOpenLogs(channel: string): void } @@ -107,6 +109,7 @@ const Level = ({ index, status, onContinue, + onRunTest, onLoadSolution, onOpenLogs, processes, @@ -181,10 +184,16 @@ const Level = ({