JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1498
  • Score
    100M100P100Q119675F
  • License MIT

Expressive Diagnostics library

Package Exports

  • @dev-build-deploy/diagnose-it
  • @dev-build-deploy/diagnose-it/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@dev-build-deploy/diagnose-it) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

DiagnoseIt - Expressive Diagnostics Library

Lightweight diagnostics logger, based on LLVMs Expressive Diagnostics specification:

Features

Usage

Create an Expressive Diagnostics message

import { ExpressiveMessage } from '@dev-build-deploy/diagnose-it';

const lines = `steps:
  - uses: actions/checkout@v2
  - neds: [build, test]
    - uses: actions/setup-node@v2`;

// Example using Method chaining
const chainedMessage = new ExpressiveMessage()
  .id("example.yaml")
  .error("Invalid keyword 'neds'")
  .lineNumber(9)
  .caret(4, 4)
  .hint("needs")
  .context(lines, 7);

// Example using constructor
const message = new ExpressiveMessage({
  id: "example.yaml",
  type: "error",
  message: "Invalid keyword 'neds'",
  lineNumber: 9,
  hint: "needs",
  caret: {
    index: 4,
    length: 4
  },
  context: {
    lines: lines,
    index: 7
  }
});

// Convert to string
console.log(chainedMessage.toString());

// Throw as an Error
throw message;

Parse a (compiler output) file

You can parse a (compiler output) file to retrieve any Expressive Diagnostic message:

import * as diagnoseIt from '@dev-build-deploy/diagnose-it';

for await(const message of diagnoseIt.extractFromFile("build.log")) {
  if (message.toJSON().type === "error") {
    // Oh noes!
  }
}

Output format

DiagnoseIt is based on the LLVMs Expressive Diagnostics formatting;

Contributing

If you have suggestions for how diagnose-it could be improved, or want to report a bug, open an issue! We'd love all and any contributions.

For more, check out the Contributing Guide.

License