https://github.com/npm/libnpmpack
Programmatic API for the bits behind npm pack
https://github.com/npm/libnpmpack
npm-cli
Last synced: 9 months ago
JSON representation
Programmatic API for the bits behind npm pack
- Host: GitHub
- URL: https://github.com/npm/libnpmpack
- Owner: npm
- License: isc
- Archived: true
- Created: 2020-03-11T19:23:01.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2022-01-18T21:33:39.000Z (over 4 years ago)
- Last Synced: 2024-10-01T16:07:19.478Z (over 1 year ago)
- Topics: npm-cli
- Language: JavaScript
- Homepage:
- Size: 652 KB
- Stars: 7
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# We've Moved! 🚚
The code for this repo is now a workspace in the npm CLI repo.
[github.com/npm/cli](https://github.com/npm/cli)
You can find the workspace in /workspaces/libnpmpack
Please file bugs and feature requests as issues on the CLI and tag the issue with "ws:libnpmpack".
[github.com/npm/cli/issues](https://github.com/npm/cli)
# libnpmpack
[](https://npm.im/libnpmpack)
[](https://npm.im/libnpmpack)
[](https://github.com/npm/libnpmpack/actions?query=workflow%3A%22Node+CI%22)
[](https://coveralls.io/github/npm/libnpmpack?branch=latest)
[`libnpmpack`](https://github.com/npm/libnpmpack) is a Node.js library for
programmatically packing tarballs from a local directory or from a registry or github spec. If packing from a local source, `libnpmpack` will also run the `prepack` and `postpack` lifecycles.
## Table of Contents
* [Example](#example)
* [Install](#install)
* [API](#api)
* [`pack()`](#pack)
## Example
```js
const pack = require('libnpmpack')
```
## Install
`$ npm install libnpmpack`
### API
#### `> pack(spec, [opts]) -> Promise`
Packs a tarball from a local directory or from a registry or github spec and returns a Promise that resolves to the tarball data Buffer, with from, resolved, and integrity fields attached.
If no options are passed, the tarball file will be saved on the same directory from which `pack` was called in.
`libnpmpack` uses [`pacote`](https://npm.im/pacote).
Most options are passed through directly to that library, so please refer to
[its own `opts`
documentation](https://www.npmjs.com/package/pacote#options)
for options that can be passed in.
##### Examples
```javascript
// packs from cwd
const tarball = await pack()
// packs from a local directory
const localTar = await pack('/Users/claudiahdz/projects/my-cool-pkg')
// packs from a registry spec
const registryTar = await pack('abbrev@1.0.3')
// packs from a github spec
const githubTar = await pack('isaacs/rimraf#PR-192')
```