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

bats-zsh

v1.2.1

Published

Wrapper enabling Bats to test functions in Zsh scripts

Downloads

35

Readme

bats-zsh

license GitHub release npm tests

Wrapper enabling Bats to source and test Zsh scripts.

Install

npm is the preferred installation method.

npm install bats-zsh

Usage

This project provides the following functions:

zsource

Used in place of source to source 1 or more Zsh files.

@test 'zsource sample test'{
    zsource path/to/zsh-file1.sh
    zsource path/to/zsh-file2.sh
}

When multiple files are sourced using zsource, conflicts will be handled the same as source would. In effect, when there is a conflict, the newer version will overwrite the older one.

zrun

Used in place of run to run a function from the sourced Zsh script.

@test 'output_number_of_args() outputs the number of args' {
    zsource path/to/zsh-file.sh
    zrun output_number_of_args arg1 arg2 arg3

    [ "$status" -eq 0 ]
    [ "$output" = "there were 3 args" ]
    [ "$BATS_RUN_COMMAND" = "zrun output_number_of_args arg1 arg2 arg3" ]
}

All variables expected from run will be set (i.e. status, output, and BATS_RUN_COMMAND).

zset

Used to set or change global variables in the sourced files.

@test 'say_my_name() outputs \$MY_NAME'{
    zsource path/to/zsh-file.sh

    zrun say_my_name

    [ "$output" = "You don't have a name" ]

    zset MY_NAME="David"

    zrun say_my_name

    [ "$output" = "Your name is David" ]
}

Testing

  1. Clone this repository: git clone https://github.com/targendaz2/bats-zsh.git
  2. Install global dependencies: Node.js, ShellCheck, & Zsh
  3. Install project dependencies: npm install
  4. Run shellcheck: npm run shellcheck
  5. Run tests: npm test test