docs: add example

This commit is contained in:
Zoltan Kochan
2018-01-07 17:53:54 +02:00
parent e1a40dd192
commit 1f5754e476
3 changed files with 27 additions and 1 deletions

1
example/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
dist

25
example/index.js Normal file
View File

@@ -0,0 +1,25 @@
'use strict'
const createFetcher = require('@pnpm/tarball-fetcher').default
process.chdir(__dirname)
const registry = 'https://registry.npmjs.org/'
const fetch = createFetcher({
registry,
rawNpmConfig: {
registry,
},
})
const resolution = {
tarball: 'https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz',
}
fetch.tarball(resolution, 'dist/unpacked', {
cachedTarballLocation: 'dist/cache.tgz',
prefix: process.cwd(),
})
.then(index => console.log(Object.keys(index)))
.catch(err => {
console.error(err)
process.exit(1)
})

View File

@@ -10,7 +10,7 @@
"scripts": {
"prepublishOnly": "npm run tsc",
"tsc": "rimraf lib && tsc",
"test": "preview && ts-node test"
"test": "preview && ts-node test && node example"
},
"repository": {
"type": "git",