🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

get-executable-bin-path

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-executable-bin-path

Get the current package's binary path and ensure it's executable.

0.1.0
latest
Source
npm
Version published
Weekly downloads
1
Maintainers
0
Weekly downloads
 
Created
Source

get-executable-bin-path

Get the current package's binary path and ensure it's executable.

Useful for making sure your CLIs are configured correctly.

Install

npm install --save-dev get-executable-bin-path
Other Package Managers

yarn add --dev get-executable-bin-path

Usage

import anyTest, { type TestFn } from "ava";
import { execa } from "execa";
import { getExecutableBinPath } from "get-executable-bin-path";

const test = anyTest as TestFn<{
	binPath: string;
}>;

test.before("setup context", async t => {
	t.context.binPath = await getExecutableBinPath();
});

test("main", async t => {
	const { stdout } = await execa(t.context.binPath);
	t.is(stdout, /* … */);
});

API

getExecutableBinPath(options?): Promise<string>

getExecutableBinPathSync(options?): string

options

Type: object

name

Type: string
Default: package.json name field

Name of the binary. See get-bin-path for more details.

cwd

Type: string
Default: process.cwd()

Override the current directory. Used when retrieving the package.json.

map

Type: (binPath: string) => string

An optional mapping that resolves to a binary's path.

This can be used to get the path of the source binary, for example.

Example

const binPath = await getExecutableBinPath();
//=> "…/dist/cli.js"

const mappedBinPath = await getExecutableBinPath({
	map: binPath => binPath.replace("dist", "src").replace(".js", ".ts"),
});
//=> "…/src/cli.ts"

BinaryPathNotFoundError

The error thrown when a given binary cannot be resolved.

BinaryNotExecutableError

The error thrown when a given binary is not executable or resolvable.

  • get-bin-path - Get the current package's binary path.
  • bin-path-cli - Execute the current package's binary.
  • is-executable - Check whether a file can be executed.
  • execa - Process execution for humans.

Keywords

nodejs

FAQs

Package last updated on 10 Jul 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