8000 fix bug with fileFormats · coderoad/coderoad-vscode@502591a · GitHub
[go: up one dir, main page]

Skip to content

Commit 502591a

Browse files
committed
fix bug with fileFormats
1 parent be36c53 commit 502591a

File tree

3 files changed

+27
-3
lines changed
  • web-app/src/services/apollo/queries
  • 3 files changed

    +27
    -3
    lines changed

    src/actions/tutorialConfig.ts

    Lines changed: 3 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,13 +1,15 @@
    11
    import * as G from 'typings/graphql'
    22
    import * as vscode from 'vscode'
    33
    import * as git from '../services/git'
    4+
    import langaugeMap from '../editor/languageMap'
    45

    56
    interface TutorialConfigParams {
    67
    config: G.TutorialConfig,
    78
    alreadyConfigured?: boolean
    89
    onComplete?(): void
    910
    }
    1011

    12+
    1113
    const tutorialConfig = async ({config, alreadyConfigured, }: TutorialConfigParams) => {
    1214
    if (!alreadyConfigured) {
    1315
    // setup git, add remote
    @@ -19,8 +21,7 @@ const tutorialConfig = async ({config, alreadyConfigured, }: TutorialConfigParam
    1921

    2022
    // setup onSave hook
    2123
    vscode.workspace.onDidSaveTextDocument((document: vscode.TextDocument) => {
    22-
    const fileFormat: string = document.languageId.toUpperCase()
    23-
    // @ts-ignore warning on enums when validating a file format match
    24+
    const fileFormat: G.FileFormat = langaugeMap[document.languageId]
    2425
    if (document.uri.scheme === 'file' && config.fileFormats.includes(fileFormat)) {
    2526
    vscode.commands.executeCommand('coderoad.run_test')
    2627
    }

    src/editor/languageMap.ts

    Lines changed: 23 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,23 @@
    1+
    import * as G from 'typings/graphql'
    2+
    // sourced from https://code.visualstudio.com/docs/languages/identifiers
    3+
    const languageMap: {
    4+
    [lang: string]: G.FileFormat
    5+
    } = {
    6+
    // go: 'GO',
    7+
    javascript: 'JS',
    8+
    javascriptreact: 'JSX',
    9+
    json: 'JSON',
    10+
    // less: 'LESS',
    11+
    // lua: 'LUA',
    12+
    // php: 'PHP',
    13+
    // python: 'PY',
    14+
    // ruby: 'RB',
    15+
    // sass: 'SASS',
    16+
    // scss: 'SCSS',
    17+
    // sql: 'SQL',
    18+
    typescript: 'TS',
    19+
    typescriptreact: 'TSX',
    20+
    // yaml: 'YAML'
    21+
    }
    22+
    23+
    export default languageMap

    web-app/src/services/apollo/queries/tutorial.ts

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -13,7 +13,7 @@ export default gql`
    1313
    data {
    1414
    config {
    1515
    testRunner
    16-
    codingLanguages
    16+
    fileFormats
    1717
    repo {
    1818
    uri
    1919
    branch

    0 commit comments

    Comments
     (0)
    0