🐜 fix: brightSCreen Entity created if dir exists
This commit is contained in:
parent
95dfbbebd8
commit
8d9ac8beba
@ -3,7 +3,7 @@
|
||||
"documentationUrl": "https://brightScreen.io/courses/Test-Lesson/",
|
||||
"lessons": [
|
||||
{
|
||||
"name": "Lesson 1",
|
||||
"name": "Lesson One",
|
||||
"location": "lessonOne/indexTest.js",
|
||||
"description": "Test Description for Lesson 1",
|
||||
"executionPrefix": "node",
|
||||
@ -12,7 +12,7 @@
|
||||
"documentationUrl": "https://brightScreen.io/courses/Test-Lesson/lesson-One/"
|
||||
},
|
||||
{
|
||||
"name": "Lesson 2",
|
||||
"name": "Lesson Two",
|
||||
"location": "lessonTwo/indexTest.js",
|
||||
"description": "Test Description for Lesson 2",
|
||||
"executionPrefix": "node",
|
||||
|
@ -6,15 +6,17 @@ const test = () => {
|
||||
const testedValue = codeFromUser(input)
|
||||
|
||||
if (testedValue === expectedOutput) {
|
||||
console.log({
|
||||
const message = {
|
||||
didPass: true,
|
||||
message: 'Passed Test 1'
|
||||
})
|
||||
}
|
||||
console.log(JSON.stringify(message))
|
||||
} else {
|
||||
console.log({
|
||||
const message = {
|
||||
didPass: false,
|
||||
message: 'Did not return expected value'
|
||||
})
|
||||
}
|
||||
console.log(JSON.stringify(message))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
const codeFromUser = function (props) {
|
||||
return props + 'js'
|
||||
} || function() { console.log('No User code Provided') }
|
||||
|
||||
return props
|
||||
}
|
||||
|
||||
const test = () => {
|
||||
const input = 'yo'
|
||||
@ -9,11 +8,17 @@ const test = () => {
|
||||
const testedValue = codeFromUser(input)
|
||||
|
||||
if (testedValue === expectedOutput) {
|
||||
console.log('Passed Test 2')
|
||||
return true
|
||||
const message = {
|
||||
didPass: true,
|
||||
message: 'Passed Test 1'
|
||||
}
|
||||
console.log(JSON.stringify(message))
|
||||
} else {
|
||||
console.log('Failed Test Two')
|
||||
return false
|
||||
const message = {
|
||||
didPass: false,
|
||||
message: 'Did not return expected value'
|
||||
}
|
||||
console.log(JSON.stringify(message))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
function (props) {
|
||||
return props + 'js'
|
||||
return props
|
||||
}
|
@ -3,19 +3,25 @@ import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import BrightScreen from '../Entities/BrightScreen'
|
||||
import LessonInterface from '../Interfaces/LessonInterface'
|
||||
import LessonsProvider from './LessonsProvider'
|
||||
|
||||
function setupBrightScreen (): void {
|
||||
const workspaceFolder: string = vscode.workspace.rootPath || ''
|
||||
let courseName: string
|
||||
let lessons: LessonInterface[]
|
||||
|
||||
let didBrightScreenExist: boolean = false
|
||||
try {
|
||||
const brightScreenPath = path.join(workspaceFolder, '.brightScreen')
|
||||
const doesBrightScreenDirectoryExist: boolean = fs.existsSync(brightScreenPath)
|
||||
if (!doesBrightScreenDirectoryExist) fs.mkdirSync(brightScreenPath)
|
||||
didBrightScreenExist = fs.existsSync(brightScreenPath)
|
||||
if (!didBrightScreenExist){
|
||||
fs.mkdirSync(brightScreenPath)
|
||||
return
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
vscode.window.showErrorMessage('Could not create .brightScreen directory')
|
||||
return
|
||||
}
|
||||
|
||||
let brightScreenCourseConfig: any
|
||||
@ -40,6 +46,13 @@ function setupBrightScreen (): void {
|
||||
lessons: lessons
|
||||
})
|
||||
|
||||
try {
|
||||
vscode.window.registerTreeDataProvider('brightScreen', new LessonsProvider())
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
return
|
||||
}
|
||||
|
||||
vscode.window.showInformationMessage(`brightScreen has been configured for ${courseName}`)
|
||||
}
|
||||
|
||||
|
@ -2,10 +2,8 @@ import * as vscode from 'vscode'
|
||||
import * as fs from 'fs'
|
||||
import BrightScreen from './Entities/BrightScreen'
|
||||
import setupBrightScreen from './UseCases/setupBrightScreen'
|
||||
import LessonsProvider from './UseCases/LessonsProvider'
|
||||
import LessonInterface from './Interfaces/LessonInterface'
|
||||
import { spawn, exec } from 'child_process'
|
||||
import { stderr } from 'process'
|
||||
import { exec } from 'child_process'
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
console.log('brightscreen is now active')
|
||||
@ -13,19 +11,9 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
let brightScreen: BrightScreen
|
||||
let workspaceFolder: string
|
||||
let lessons: LessonInterface[]
|
||||
const outputChannel: vscode.OutputChannel = vscode.window.createOutputChannel('brightScreen')
|
||||
|
||||
setupBrightScreen()
|
||||
brightScreen = BrightScreen.getInstance()
|
||||
workspaceFolder = brightScreen.workspaceFolder
|
||||
lessons = brightScreen.lessons
|
||||
|
||||
try {
|
||||
vscode.window.registerTreeDataProvider('brightScreen', new LessonsProvider())
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
|
||||
const startupBrightScreenCommand = vscode.commands.registerCommand('brightscreen.startBrightScreen', (value) => {
|
||||
const startupBrightScreenCommand = vscode.commands.registerCommand('brightscreen.startBrightScreen', () => {
|
||||
setupBrightScreen()
|
||||
brightScreen = BrightScreen.getInstance()
|
||||
workspaceFolder = brightScreen.workspaceFolder
|
||||
@ -82,7 +70,29 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
console.log('exec error: ', error)
|
||||
}
|
||||
|
||||
console.log(stdout)
|
||||
let output: { didPass: boolean, message: string }
|
||||
try {
|
||||
output = JSON.parse(stdout)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
outputChannel.appendLine('Problem reading code from active text editor. Make sure to focus on the code you wish to test.')
|
||||
vscode.window.showErrorMessage(`Issue receiving test results from ${treeItemContext.label}`, 'Read More').then( selection => {
|
||||
if (selection === 'Read More') outputChannel.show()
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
outputChannel.appendLine(`${treeItemContext.label}: ${output.message}`)
|
||||
|
||||
if (output.didPass) {
|
||||
vscode.window.showInformationMessage(`${treeItemContext.label} Passed!`, 'Read More').then( selection => {
|
||||
if (selection === 'Read More') outputChannel.show()
|
||||
})
|
||||
} else {
|
||||
vscode.window.showErrorMessage(`${treeItemContext.label} Failed!`).then( selection => {
|
||||
if (selection === 'Read More') outputChannel.show()
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user