Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@yarn-tool/get-pkg-bin

bluelovers1.4kISC2.0.12TypeScript support: included

get bin script from package.json

readme

README.md

get bin script from package.json

install

yarn add @yarn-tool/get-pkg-bin
yarn-tool add @yarn-tool/get-pkg-bin

api

import type { IPackageJson } from '@ts-type/package-dts';
export declare type IOptions = {
    pkgRoot?: string;
    usePathResolve?: boolean;
} & ({
    name?: string;
    pkg: IPackageJson | Record<string, any>;
} | {
    name: string;
    pkg?: IPackageJson | Record<string, any>;
});
export declare function normalizePackageBins(options: IOptions): Record<string, string>;
export declare function defaultPackageBin(options: IOptions, defaultKey?: string): string;
export default normalizePackageBins;

demo

import { normalizePackageBins} from '../index';
import { resolvePackage } from '@yarn-tool/resolve-package';

let bins = normalizePackageBins({
    ...resolvePackage('ts-node'),
});

console.dir(bins)

bins = normalizePackageBins({
    ...resolvePackage('ts-node'),

    usePathResolve: true,
});

console.dir(bins)

bins = normalizePackageBins({
    //pkgRoot: dirname(require.resolve('ts-node/package.json')),
    pkg: resolvePackage('ts-node').pkg,
    usePathResolve: true,
});

console.dir(bins)

bins = normalizePackageBins({
    name: 'ts-node',
});

console.dir(bins)

=>

{
  'ts-node': 'C:/Users/User/AppData/Roaming/npm/node_modules/ts-node/dist/bin.js',
  'ts-script': 'C:/Users/User/AppData/Roaming/npm/node_modules/ts-node/dist/script.js'
}
{
  'ts-node': 'C:/Users/User/AppData/Roaming/npm/node_modules/ts-node/dist/bin.js',
  'ts-script': 'C:/Users/User/AppData/Roaming/npm/node_modules/ts-node/dist/script.js'
}
{ 'ts-node': './dist/bin.js', 'ts-script': './dist/script.js' }
{
  'ts-node': 'C:/Users/User/AppData/Roaming/npm/node_modules/ts-node/dist/bin.js',
  'ts-script': 'C:/Users/User/AppData/Roaming/npm/node_modules/ts-node/dist/script.js'
}

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

2.0.12 (2024-05-03)

🛠 Build System

2.0.11 (2022-11-14)

📌 Dependencies

2.0.10 (2022-10-28)

📌 Dependencies

🔖 Miscellaneous

2.0.9 (2022-10-01)

🔖 Miscellaneous

2.0.8 (2022-09-29)

🔖 Miscellaneous

2.0.7 (2022-09-28)

📌 Dependencies

2.0.6 (2022-09-27)

🔖 Miscellaneous

2.0.5 (2022-09-27)

Note: Version bump only for package @yarn-tool/get-pkg-bin

2.0.4 (2022-09-06)

📚 Documentation

🔖 Miscellaneous

2.0.3 (2022-08-26)

🔖 Miscellaneous

2.0.2 (2022-08-13)

Note: Version bump only for package @yarn-tool/get-pkg-bin

2.0.1 (2022-08-13)

🚨 Tests

  • update jest.config.js and deps (d1d501b)

🛠 Build System

📌 Dependencies

2.0.0 (2022-07-07)

♻️ Dependencies

1.0.51 (2022-05-11)

♻️ Chores

1.0.50 (2022-03-14)

Note: Version bump only for package @yarn-tool/get-pkg-bin

1.0.49 (2022-02-27)

♻️ Chores

1.0.48 (2022-02-27)

♻️ Chores

1.0.47 (2022-02-19)

Note: Version bump only for package @yarn-tool/get-pkg-bin

1.0.46 (2022-01-13)

♻️ Chores

1.0.45 (2021-12-31)

📦 Code Refactoring

1.0.44 (2021-12-16)

🔖 Miscellaneous

1.0.43 (2021-12-06)

♻️ Chores

1.0.42 (2021-11-28)

♻️ Chores

1.0.41 (2021-11-23)

♻️ Chores

1.0.40 (2021-11-03)

Note: Version bump only for package @yarn-tool/get-pkg-bin

1.0.39 (2021-11-03)

Note: Version bump only for package @yarn-tool/get-pkg-bin

1.0.38 (2021-09-15)

♻️ Chores

1.0.37 (2021-08-13)

♻️ Chores

1.0.36 (2021-07-23)

♻️ Chores

1.0.35 (2021-07-16)

🐛 Bug Fixes

✨ Features

🔖 Miscellaneous

1.0.34 (2021-07-16)

✨ Features

1.0.33 (2021-07-11)

🛠 Build System

♻️ Chores

🔖 Miscellaneous

1.0.32 (2021-07-11)

🛠 Build System

♻️ Chores

1.0.31 (2021-06-21)

♻️ Chores

1.0.30 (2021-06-02)

🚨 Tests

♻️ Chores

1.0.29 (2021-02-12)

♻️ Chores

1.0.28 (2020-09-04)

♻️ Chores

1.0.27 (2020-08-09)

♻️ Chores

1.0.26 (2020-07-31)

♻️ Chores

1.0.25 (2020-07-28)

♻️ Chores

1.0.24 (2020-07-27)

♻️ Chores

1.0.23 (2020-07-26)

♻️ Chores

1.0.22 (2020-07-24)

♻️ Chores

1.0.21 (2020-07-18)

♻️ Chores

1.0.20 (2020-07-12)

🛠 Build System

1.0.19 (2020-07-12)

♻️ Chores

1.0.18 (2020-07-05)

♻️ Chores

1.0.17 (2020-06-27)

♻️ Chores

1.0.16 (2020-06-19)

🔖 Miscellaneous

1.0.15 (2020-06-19)

♻️ Chores

1.0.14 (2020-06-16)

Note: Version bump only for package @yarn-tool/get-pkg-bin

1.0.13 (2020-06-13)

Note: Version bump only for package @yarn-tool/get-pkg-bin

1.0.12 (2020-06-12)

Bug Fixes

1.0.11 (2020-06-12)

Features

  • @yarn-tool/check-pkg-bin (f3e24f0)

1.0.10 (2020-06-11)

Bug Fixes

  • update @ts-type/package-dts (b44d2aa)

1.0.9 (2020-06-11)

Note: Version bump only for package @yarn-tool/get-pkg-bin

1.0.8 (2020-06-11)

Features

1.0.7 (2020-06-09)

Note: Version bump only for package @yarn-tool/get-pkg-bin

1.0.6 (2020-06-09)

Note: Version bump only for package @yarn-tool/get-pkg-bin

1.0.5 (2020-06-06)

Note: Version bump only for package @yarn-tool/get-pkg-bin