New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

terminator-command-builder

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

terminator-command-builder

A library to build and execute terminal commands interactively.

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

Terminator Command Builder

The Terminator Command Builder is a JavaScript library that provides utilities for constructing command strings in a structured manner. It allows you to easily build complex command strings by chaining methods to add string literals, regular expressions, or transformation functions.

Installation

You can install the terminator-command-builder library via npm:

npm install terminator-command-builder

Usage

Here's how you can use the library to construct command strings:

const CommandBuilder = require('terminator-command-builder');

const command = new CommandBuilder()
  .literal('echo ')
  .transform(input => input.toUpperCase())
  .literal(' ')
  .regex(/hello/)
  .build();

console.log(command); // Output: echo HELLO hello

API

CommandBuilder()

Creates a new instance of the CommandBuilder.

literal(part: string): CommandBuilder

Adds a string literal to the command.

  • part: The string part to add.

regex(regex: RegExp): CommandBuilder

Adds a regular expression to match part of the command.

  • regex: The regular expression to match.

transform(transformer: function): CommandBuilder

Adds a function to transform input string.

  • transformer: The function to transform input.

build(): string

Builds the final command string.

Returns:

  • string: The constructed command string.

Example

const command = new CommandBuilder()
  .literal('echo ')
  .transform(input => input.toUpperCase())
  .literal(' ')
  .regex(/hello/)
  .build();

console.log(command); // Output: echo HELLO hello

License

This library is licensed under the MIT License. See the LICENSE file for details.

FAQs

Package last updated on 17 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts