1.1.0 • Published 5 years ago

shell-api v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

shell-api

Build Status NPM version GitHub version

Overview

A robust set of POSIX-compliant scripts for shell environments.

Shell support

The goal is to provide a simple API that is compatible with Bourne-like shells on *nix systems.

All functions have been tested in bash, dash, fish, ksh, and zsh.

The API


Getting started

Install

  • Install this project via npm.

    npm i shell-api --save
  • Symlink the shell directory within a project.

    ln -s ./node_modules/shell-api/shell ./.shell

Usage

Method A

#!/usr/bin/env sh

script_path=$(cd "$(dirname "${0}")"; pwd)
shell_api_path="${script_path}/../.shell"

# Load the whole framework at once
. "${shell_api_path}"/shell-api

export-file ./.env
require <SCRIPT>

...

Method B

#!/usr/bin/env sh

script_path=$(cd "$(dirname "${0}")"; pwd)
shell_api_path="${script_path}/../.shell"

# Selectively load parts of the framework
. "${shell_api_path}"/strict-mode
. "${shell_api_path}"/export-file
. "${shell_api_path}"/require

export-file ./.env
require <SCRIPT>

...
1.1.0

5 years ago

1.0.0

6 years ago

0.2.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago