mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-04 14:08:44 -04:00
docs: add example
This commit is contained in:
1
example/.gitignore
vendored
Normal file
1
example/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
dist
|
||||
25
example/index.js
Normal file
25
example/index.js
Normal 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)
|
||||
})
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user