Détail du package

bin-links

npm15.1mISC5.0.0

JavaScript package binary linker

npm, link, bins

readme

bin-links npm version license Travis AppVeyor Coverage Status

bin-links is a standalone library that links binaries and man pages for JavaScript packages

Install

$ npm install bin-links

Table of Contents

Example

const binLinks = require('bin-links')
const readPackageJson = require('read-package-json-fast')
binLinks({
  path: '/path/to/node_modules/some-package',
  pkg: readPackageJson('/path/to/node_modules/some-package/package.json'),

  // true if it's a global install, false for local.  default: false
  global: true,

  // true if it's the top level package being installed, false otherwise
  top: true,

  // true if you'd like to recklessly overwrite files.
  force: true,
})

Features

  • Links bin files listed under the bin property of pkg to the node_modules/.bin directory of the installing environment. (Or ${prefix}/bin for top level global packages on unix, and ${prefix} for top level global packages on Windows.)
  • Links man files listed under the man property of pkg to the share/man directory. (This is only done for top-level global packages on Unix systems.)

Contributing

The npm team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The Contributor Guide has all the information you need for everything from reporting bugs to contributing entire new features. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear.

API

> binLinks({path, pkg, force, global, top})

Returns a Promise that resolves when the requisite things have been linked.

> binLinks.getPaths({path, pkg, global, top })

Returns an array of all the paths of links and shims that might be created (assuming that they exist!) for the package at the specified path.

Does not touch the filesystem.

> binLinks.checkBins({path, pkg, global, top, force })

Checks if there are any conflicting bins which will prevent the linking of bins for the given package. Returns a Promise that resolves with no value if the way is clear, and rejects if there's something in the way.

Always returns successfully if global or top are false, or if force is true, or if the pkg object does not contain any bins to link.

Note that changes to the file system may still cause the binLinks method to fail even if this method succeeds. Does not check for conflicting man links.

Reads from the filesystem but does not make any changes.

Example
binLinks({path, pkg, force, global, top}).then(() => console.log('bins linked!'))

changelog

Changelog

5.0.0 (2024-09-25)

⚠️ BREAKING CHANGES

  • bin-links now supports node ^18.17.0 || >=20.5.0

    Features

  • 9648a7d #121 ignore EACCES on linking (@antongolub)

    Bug Fixes

  • 013be50 #139 align to npm 10 node engine range (@reggi)

    Dependencies

  • a08d09b #139 write-file-atomic@6.0.0
  • 7d90298 #139 read-cmd-shim@5.0.0
  • 0c915a3 #139 proc-log@5.0.0
  • 502417c #139 npm-normalize-package-bin@4.0.0
  • 722452a #139 cmd-shim@7.0.0
  • af7e347 #121 add proc-log

    Chores

  • 463c32f #139 run template-oss-apply (@reggi)
  • ba52600 #133 bump @npmcli/eslint-config from 4.0.5 to 5.0.0 (@dependabot[bot])
  • fdf22ae #134 postinstall for dependabot template-oss PR (@hashtagchris)
  • d949f7d #134 bump @npmcli/template-oss from 4.23.1 to 4.23.3 (@dependabot[bot])

4.0.4 (2024-05-04)

Bug Fixes

Chores

  • e955437 #117 bump @npmcli/template-oss to 4.22.0 (@lukekarrys)
  • b602aca #117 postinstall for dependabot template-oss PR (@lukekarrys)
  • 955cc34 #116 bump @npmcli/template-oss from 4.21.3 to 4.21.4 (@dependabot[bot])

4.0.3 (2023-10-12)

Bug Fixes

  • af17744 #100 promisify/cleanup link-mans and simplify regex (#100) (@wraithgar)

4.0.2 (2023-07-11)

Bug Fixes

  • 08f8981 #80 don’t try to chmod unlinked files (#80) (@remcohaszing)

4.0.1 (2022-10-17)

Dependencies

  • cf738fb #62 bump read-cmd-shim from 3.0.1 to 4.0.0
  • 61717bf #64 bump write-file-atomic from 4.0.2 to 5.0.0
  • d26ec29 #61 bump npm-normalize-package-bin from 2.0.0 to 3.0.0

4.0.0 (2022-10-13)

⚠️ BREAKING CHANGES

  • this module no longer attempts to change file ownership automatically
  • bin-links is now compatible with the following semver range for node: ^14.17.0 || ^16.13.0 || >=18.0.0

Features

  • 4f4c58c #59 do not alter file ownership (#59) (@nlf)
  • 36b2668 #52 postinstall for dependabot template-oss PR (@lukekarrys)

3.0.3 (2022-08-23)

Dependencies

  • bump npm-normalize-package-bin from 1.0.1 to 2.0.0 (#50) (3ffe1e9)

3.0.2 (2022-08-11)

Bug Fixes

3.0.1 (2022-04-05)

Bug Fixes

  • remove unsafe regex (5d01244)
  • replace deprecated String.prototype.substr() (#38) (56dbfa0)

Dependencies

  • bump cmd-shim from 4.1.0 to 5.0.0 (#39) (24a1f3c)
  • bump read-cmd-shim from 2.0.0 to 3.0.0 (#40) (36a652f)

3.0.0 (2022-01-18)

⚠ BREAKING CHANGES

  • This drops support for node10 and non-LTS versions of node12 and node14

Bug Fixes

dependencies

2.0.0

  • Rewrite to promisify and remove dependence on gentle-fs

1.1.7 (2019-12-26)

Bug Fixes

  • resolve folder that is passed in (0bbd303)

1.1.6 (2019-12-11)

Bug Fixes

  • prevent improper clobbering of man/bin links (642cd18), closes #11 #12

1.1.5 (2019-12-10)

Bug Fixes

  • don't filter out ./ man references (b3cfd2e)

1.1.4 (2019-12-09)

Bug Fixes

  • sanitize and validate bin and man link targets (25a34f9)

1.1.3 (2019-08-14)

1.1.2 (2018-03-22)

Bug Fixes

  • linkMans: return the promise! (5eccc7f)

1.1.1 (2018-03-07)

Bug Fixes

  • shebangs: only convert CR when doing CRLF -> LF (#2) (43bf857)

1.1.0 (2017-11-20)

Features

  • dos2unix: Log the fact line endings are being changed upon install. (e9f8a6f)

1.0.0 (2017-10-07)

Features

  • import: initial extraction from npm (6ed0bfb)
  • initial commit: README (3fc9cf0)