GithubHelp home page GithubHelp logo

jchavarri / bsb-vscode-task-adaptor Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 0.0 2.11 MB

A script that integrates the output from bsb into vscode tasks using problem matchers

License: MIT License

JavaScript 100.00%
bucklescript vscode vscode-tasks bsb reasonml ocaml

bsb-vscode-task-adaptor's Introduction

bsb-vscode-task-adaptor

NPM

A small Node.js script that reads the output from BuckleScript build tool (bsb) and adapts it so it can be consumed from vscode tasks, so they appear in the "Problems" panel of vscode that shows project diagnostics.

Demo

Getting started

Just three steps.

a. Install the package:

npm install --save-dev bsb-vscode-task-adaptor

or with yarn:

yarn add bsb-vscode-task-adaptor --dev

b. In your project main folder, create a folder .vscode and inside, a file tasks.json like the one shown below. The json will have npm and commands and two arguments passed in args:

  1. parse-bsb is the name of this package script.
  2. The command that parse-bsb will run by changing the second element passed to args (bsb -make-world -w in the example below).

Example tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "bsb watch",
      "command": "npx",
      "type": "shell",
      "args": ["parse-bsb", "bsb -make-world -w"],
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": false,
        "panel": "shared"
      },
      "isBackground": true,
      "problemMatcher": {
        "fileLocation": "absolute",
        "owner": "ocaml",
        "background": {
          "activeOnStart": true,
          "beginsPattern": ">>>> Start compiling",
          "endsPattern": ">>>> Finish compiling"
        },
        "pattern": [
          {
            "regexp": "^File \"(.*)\", lines (\\d+)-(\\d+)(?:, characters (\\d+)-(\\d+))?:$",
            "file": 1,
            "line": 2,
            "endLine": 3,
            "column": 4,
            "endColumn": 5
          },
          {
            "regexp": "^(?:(?:Parse\\s+)?([Ww]arning|[Ee]rror)(?:\\s+\\d+)?:)?\\s+(.*)$",
            "severity": 1,
            "message": 2
          }
        ]
      }
    }
  ]
}

c. Run the newly created task by pressing โ‡งโŒ˜B or from "Run Build Task" in the "Terminal" menu.

You should see the diagnostics appearing in vscode "Problems" panel.

Why

Some of the reasons why this tool might be useful for you:

  • vscode problem matchers do not support multiline messages, so using a plain task would only show the first line of the message, leaving useful information out of the diagnostics panel. See microsoft/vscode#9635
  • bsb uses super-errors by default for Reason projects. While super errors are really nice to better understand what's happening in the console, the format is very different from the original OCaml / BuckleScript errors, which makes them harder to parse. Unfortunately, super-errors can't be disabled for Reason projects and this configuration is not editable. See rescript-lang/rescript-compiler#3446
  • Existing Reason / OCaml extensions for vscode that call bsb behind the scenes might lead to conflicts over files when the build commands are started manually too. The lack of transparency in the process leads often to confusion as well, as the output from bsb when it is called from the extension is not made visible for users. This adaptor shows the raw output from bsb, as well as the parsed string in the "Terminal" panel of vscode.

bsb-vscode-task-adaptor's People

Contributors

jchavarri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bsb-vscode-task-adaptor's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.