🐜 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/",
|
"documentationUrl": "https://brightScreen.io/courses/Test-Lesson/",
|
||||||
"lessons": [
|
"lessons": [
|
||||||
{
|
{
|
||||||
"name": "Lesson 1",
|
"name": "Lesson One",
|
||||||
"location": "lessonOne/indexTest.js",
|
"location": "lessonOne/indexTest.js",
|
||||||
"description": "Test Description for Lesson 1",
|
"description": "Test Description for Lesson 1",
|
||||||
"executionPrefix": "node",
|
"executionPrefix": "node",
|
||||||
@ -12,7 +12,7 @@
|
|||||||
"documentationUrl": "https://brightScreen.io/courses/Test-Lesson/lesson-One/"
|
"documentationUrl": "https://brightScreen.io/courses/Test-Lesson/lesson-One/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Lesson 2",
|
"name": "Lesson Two",
|
||||||
"location": "lessonTwo/indexTest.js",
|
"location": "lessonTwo/indexTest.js",
|
||||||
"description": "Test Description for Lesson 2",
|
"description": "Test Description for Lesson 2",
|
||||||
"executionPrefix": "node",
|
"executionPrefix": "node",
|
||||||
|
@ -6,15 +6,17 @@ const test = () => {
|
|||||||
const testedValue = codeFromUser(input)
|
const testedValue = codeFromUser(input)
|
||||||
|
|
||||||
if (testedValue === expectedOutput) {
|
if (testedValue === expectedOutput) {
|
||||||
console.log({
|
const message = {
|
||||||
didPass: true,
|
didPass: true,
|
||||||
message: 'Passed Test 1'
|
message: 'Passed Test 1'
|
||||||
})
|
}
|
||||||
|
console.log(JSON.stringify(message))
|
||||||
} else {
|
} else {
|
||||||
console.log({
|
const message = {
|
||||||
didPass: false,
|
didPass: false,
|
||||||
message: 'Did not return expected value'
|
message: 'Did not return expected value'
|
||||||
})
|
}
|
||||||
|
console.log(JSON.stringify(message))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
const codeFromUser = function (props) {
|
const codeFromUser = function (props) {
|
||||||
return props + 'js'
|
return props
|
||||||
} || function() { console.log('No User code Provided') }
|
}
|
||||||
|
|
||||||
|
|
||||||
const test = () => {
|
const test = () => {
|
||||||
const input = 'yo'
|
const input = 'yo'
|
||||||
@ -9,11 +8,17 @@ const test = () => {
|
|||||||
const testedValue = codeFromUser(input)
|
const testedValue = codeFromUser(input)
|
||||||
|
|
||||||
if (testedValue === expectedOutput) {
|
if (testedValue === expectedOutput) {
|
||||||
console.log('Passed Test 2')
|
const message = {
|
||||||
return true
|
didPass: true,
|
||||||
|
message: 'Passed Test 1'
|
||||||
|
}
|
||||||
|
console.log(JSON.stringify(message))
|
||||||
} else {
|
} else {
|
||||||
console.log('Failed Test Two')
|
const message = {
|
||||||
return false
|
didPass: false,
|
||||||
|
message: 'Did not return expected value'
|
||||||
|
}
|
||||||
|
console.log(JSON.stringify(message))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
function (props) {
|
function (props) {
|
||||||
return props + 'js'
|
return props
|
||||||
}
|
}
|
@ -3,19 +3,25 @@ import * as fs from 'fs'
|
|||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import BrightScreen from '../Entities/BrightScreen'
|
import BrightScreen from '../Entities/BrightScreen'
|
||||||
import LessonInterface from '../Interfaces/LessonInterface'
|
import LessonInterface from '../Interfaces/LessonInterface'
|
||||||
|
import LessonsProvider from './LessonsProvider'
|
||||||
|
|
||||||
function setupBrightScreen (): void {
|
function setupBrightScreen (): void {
|
||||||
const workspaceFolder: string = vscode.workspace.rootPath || ''
|
const workspaceFolder: string = vscode.workspace.rootPath || ''
|
||||||
let courseName: string
|
let courseName: string
|
||||||
let lessons: LessonInterface[]
|
let lessons: LessonInterface[]
|
||||||
|
|
||||||
|
let didBrightScreenExist: boolean = false
|
||||||
try {
|
try {
|
||||||
const brightScreenPath = path.join(workspaceFolder, '.brightScreen')
|
const brightScreenPath = path.join(workspaceFolder, '.brightScreen')
|
||||||
const doesBrightScreenDirectoryExist: boolean = fs.existsSync(brightScreenPath)
|
didBrightScreenExist = fs.existsSync(brightScreenPath)
|
||||||
if (!doesBrightScreenDirectoryExist) fs.mkdirSync(brightScreenPath)
|
if (!didBrightScreenExist){
|
||||||
|
fs.mkdirSync(brightScreenPath)
|
||||||
|
return
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
vscode.window.showErrorMessage('Could not create .brightScreen directory')
|
vscode.window.showErrorMessage('Could not create .brightScreen directory')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let brightScreenCourseConfig: any
|
let brightScreenCourseConfig: any
|
||||||
@ -39,6 +45,13 @@ function setupBrightScreen (): void {
|
|||||||
courseName: courseName,
|
courseName: courseName,
|
||||||
lessons: lessons
|
lessons: lessons
|
||||||
})
|
})
|
||||||
|
|
||||||
|
try {
|
||||||
|
vscode.window.registerTreeDataProvider('brightScreen', new LessonsProvider())
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
vscode.window.showInformationMessage(`brightScreen has been configured for ${courseName}`)
|
vscode.window.showInformationMessage(`brightScreen has been configured for ${courseName}`)
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,8 @@ import * as vscode from 'vscode'
|
|||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
import BrightScreen from './Entities/BrightScreen'
|
import BrightScreen from './Entities/BrightScreen'
|
||||||
import setupBrightScreen from './UseCases/setupBrightScreen'
|
import setupBrightScreen from './UseCases/setupBrightScreen'
|
||||||
import LessonsProvider from './UseCases/LessonsProvider'
|
|
||||||
import LessonInterface from './Interfaces/LessonInterface'
|
import LessonInterface from './Interfaces/LessonInterface'
|
||||||
import { spawn, exec } from 'child_process'
|
import { exec } from 'child_process'
|
||||||
import { stderr } from 'process'
|
|
||||||
|
|
||||||
export function activate(context: vscode.ExtensionContext) {
|
export function activate(context: vscode.ExtensionContext) {
|
||||||
console.log('brightscreen is now active')
|
console.log('brightscreen is now active')
|
||||||
@ -13,19 +11,9 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
let brightScreen: BrightScreen
|
let brightScreen: BrightScreen
|
||||||
let workspaceFolder: string
|
let workspaceFolder: string
|
||||||
let lessons: LessonInterface[]
|
let lessons: LessonInterface[]
|
||||||
|
const outputChannel: vscode.OutputChannel = vscode.window.createOutputChannel('brightScreen')
|
||||||
|
|
||||||
setupBrightScreen()
|
const startupBrightScreenCommand = vscode.commands.registerCommand('brightscreen.startBrightScreen', () => {
|
||||||
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) => {
|
|
||||||
setupBrightScreen()
|
setupBrightScreen()
|
||||||
brightScreen = BrightScreen.getInstance()
|
brightScreen = BrightScreen.getInstance()
|
||||||
workspaceFolder = brightScreen.workspaceFolder
|
workspaceFolder = brightScreen.workspaceFolder
|
||||||
@ -82,7 +70,29 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
console.log('exec error: ', error)
|
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