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 🙏

© 2026 – Pkg Stats / Ryan Hefner

gulp-sonar2

v3.2.0

Published

Sonar runner for gulp.

Readme

gulp-sonar2

Run SonarQube analysis from a gulp task. This plugin bundles the SonarScanner CLI and drives it for you, so all you need to provide is your project configuration.

Legacy line (3.x). This release keeps the original, battle-tested behaviour: it ships the bundled SonarScanner CLI 3.1 and runs it via Java. It is intended for existing users who want a maintained drop-in with up-to-date dependencies. If you are starting fresh or targeting a modern SonarQube server, consider the next-generation version (see Roadmap).

Requirements

  • Node.js >= 12
  • A Java Runtime Environment on the PATH (the bundled SonarScanner CLI 3.1 is a Java tool and needs java to run)
  • Access to a running SonarQube server

Install

npm install --save-dev gulp-sonar2

Usage

const gulp = require('gulp');
const sonar = require('gulp-sonar2');
const log = require('fancy-log');

gulp.task('sonar', function () {
    const options = {
        sonar: {
            host: {
                url: 'http://localhost:9000'
            },
            // Authentication token for the SonarQube server (recommended).
            login: process.env.SONAR_TOKEN,
            projectKey: 'my-project',
            projectName: 'My Project',
            projectVersion: '1.0.0',
            // Comma-delimited string of source directories.
            sources: 'src/app/js,src/libs/js',
            language: 'js',
            sourceEncoding: 'UTF-8',
            javascript: {
                lcov: {
                    reportPath: 'test/sonar_report/lcov.info'
                }
            },
            exec: {
                // Passed straight to child_process.exec (see:
                // https://nodejs.org/api/child_process.html#child_processexeccommand-options-callback ).
                // Raise this if the scanner produces a lot of output; exceeding
                // maxBuffer kills the child process and fails the task.
                maxBuffer: 1024 * 1024
            }
        }
    };

    // The gulp source is ignored; every file the scanner needs is referenced
    // through the options object above.
    return gulp.src('thisFileDoesNotExist.js', { read: false })
        .pipe(sonar(options))
        .on('error', log.error);
});

Options

Everything under options.sonar is flattened into sonar.* analysis properties and written to the scanner's properties file. Nested objects become dotted keys, so:

host: { url: 'http://localhost:9000' }

becomes sonar.host.url=http://localhost:9000.

Defaults applied for you:

  • sonar.sourceEncoding defaults to UTF-8
  • sonar.host.url defaults to http://localhost:9000

The exec key is special: it is not sent to the scanner, but forwarded to Node's child_process.exec so you can tune things like maxBuffer, cwd, or env.

For the full list of analysis parameters, see the SonarScanner documentation.

Error handling

The plugin emits errors on the stream rather than throwing, so attach an error handler (as shown above). The task fails if the properties file cannot be written, if java cannot be launched, or if the scanner exits with a non-zero code.

Roadmap

A next-generation rewrite (gulp-sonar-next) is planned that drops the bundled Java scanner in favour of the officially maintained Node scanner, which downloads the correct SonarScanner automatically and works with current SonarQube servers. The 3.x line documented here remains available for existing integrations.

Credit

Inspired by grunt-sonar-runner by Suresh Khatri. Forked from gulp-sonar by carsdotcom.

License

Apache-2.0