npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pipe-if-ci

v0.0.3

Published

Node.js implementation of a command to run pipeline only when in a CI environment.

Downloads

1

Readme

pipe-if-ci

Node.js implementation of a command to run pipeline only when in a CI environment.

Installation

$ npm install -D pipe-if-ci

Usage

$ pipe-if-ci --help
Run pipeline only when in a CI environment.

pipe-if-ci <command> [--pipe|-p <command-for-ci>]

Options:
  -p, --pipe     run your program                            [string] [required]
  -h, --help     Show help                                             [boolean]

Examples:
      pipe-if-ci 'tsc --noEmit' --pipe 'reviewdog -f=tsc -reporter=github-check -fail-on-error'

Use Cases: GitHub Annotations

GitHub Actions has a mechanism called Problem Matchers. If you output error messages that matches a Problem Matchers, the messages are displayed inline on the "Files changed" tab of the Pull Request. This inline error messages is called a GitHub Annotations.

The screenshot of GitHub Annotations

However, GitHub Annotation by Problem Matchers does not work for error messages containing paths relative to non-repository root directory. For example, in mono-repo, there is a problem with tsc error messages in individual packages not being displayed inline by GitHub Annotation.

To solve this problem, you can use Reviewdog. Reviewdog can interpret relative paths based on the current working directory and display GitHub Annotation using the @actions/core API.

To use this workaround, simply rewrite npm-script as follows:

  "scripts": {
-   "lint": "tsc --noEmit",
+   "lint": "tsc --noEmit | reviewdog -f=tsc -reporter=github-check -fail-on-error",
  }

However, this approach has the following disadvantages

  • Requires installation of reviewdog in the local environment as well
  • In the local environment, color is lost from the colorful logs of tsc.

This is where pipe-if-ci comes in: with pipe-if-ci, you can easily write an npm-script that pipes the output of tsc to reviewdog in the CI environment and displays the output of tsc directly in the terminal in the local environment.

  "scripts": {
-   "lint": "tsc --noEmit",
+   "lint": "pipe-if-ci 'tsc --noEmit' --pipe 'reviewdog -f=tsc -reporter=github-check -fail-on-error'",
  }

Try it out! :)

The screenshot of GitHub Annotations with pipe-if-ci

Programmable API

See src/index.js for full API implementation and details.

import { pipeIfCI } from 'pipe-if-ci';

await pipeIfCI('tsc --noEmit', { pipe: 'reviewdog -f=tsc -reporter=github-check -fail-on-error' });

License

MIT