• Home
Name Date Size #Lines LOC

..--

lib/12-May-2024-7052

LICENSED12-May-2024717 1411

README.mdD12-May-20241.7 KiB5637

package.jsonD12-May-20241.5 KiB5958

README.md

1# libnpmpack
2
3[![npm version](https://img.shields.io/npm/v/libnpmpack.svg)](https://npm.im/libnpmpack)
4[![license](https://img.shields.io/npm/l/libnpmpack.svg)](https://npm.im/libnpmpack)
5[![CI - libnpmpack](https://github.com/npm/cli/actions/workflows/ci-libnpmpack.yml/badge.svg)](https://github.com/npm/cli/actions/workflows/ci-libnpmpack.yml)
6
7[`libnpmpack`](https://github.com/npm/libnpmpack) is a Node.js library for
8programmatically 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.
9
10## Table of Contents
11
12* [Example](#example)
13* [Install](#install)
14* [API](#api)
15  * [`pack()`](#pack)
16
17## Example
18
19```js
20const pack = require('libnpmpack')
21```
22
23## Install
24
25`$ npm install libnpmpack`
26
27### API
28
29#### <a name="pack"></a> `> pack(spec, [opts]) -> Promise`
30
31Packs 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.
32
33If no options are passed, the tarball file will be saved on the same directory from which `pack` was called in.
34
35`libnpmpack` uses [`pacote`](https://npm.im/pacote).
36Most options are passed through directly to that library, so please refer to
37[its own `opts`
38documentation](https://www.npmjs.com/package/pacote#options)
39for options that can be passed in.
40
41##### Examples
42
43```javascript
44// packs from cwd
45const tarball = await pack()
46
47// packs from a local directory
48const localTar = await pack('/Users/claudiahdz/projects/my-cool-pkg')
49
50// packs from a registry spec
51const registryTar = await pack('abbrev@1.0.3')
52
53// packs from a github spec
54const githubTar = await pack('isaacs/rimraf#PR-192')
55```
56