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

drone-env-parser

v1.2.0

Published

A simple parser that converts drones PLUGIN_ environment variables to a simple js object

Downloads

9

Readme

drone-env-parser Build Status

This simple package allows you to conveniently parse the environment variables generated by drone via the settings section into a plain js object

Usage:

The most basic usage of this package looks like this:

const settings = require('drone-env-parser').parseEnvs();
// Now you can access your settings simply by referencing them like this for example:
Webservice.auth(settings.username, settings.password);

Configuration:

This package provides very basic configuration options which can be provided to it like this:

const settings = require('drone-env-parser').parseEnvs({
    // settings go here
});

Defaults

You can provide default values that will be overwritten by the values parsed from the environment variables

let settings = rquire('drone-env-parser').parseEnvs({
  defaults: {
    // define defaults here
  }
});

Splitting on comma:

If in the .drone.yml a list is provided at the top level like this:

steps:
 - name: Something
   image: also/something
   settings:
     a_list:
      - element 1
      - element 2
      - element 3

It gets encoded by drone into comma separated values and the environment variable resulting from that would look like this:

PLUGIN_A_LIST=element 1,element 2,element 3

So if you enable splitOnComma (which is disabled by default) it will split every top level string at every comma. A side effect of this is, that every top level string will be an array.

If this behaviour is desired, you can enable it by setting splitOnComma: true.

Making names lowercase

By default this package will always turn top level property names into lowercase, as drone provides the environment variables as all uppercase.

If this behaviour is not desired, you can disable it by setting makeNameLowerCase: false

Custom prefix

By default this package will filter the environment variables out that don't start with PLUGIN_ and the parse the name beginning after the PLUGIN_.

If, for what ever reason this needs to be changed, you can modify the prefix this package will look for by setting prefix: 'CUSTOM_'.