{"id":17472723,"url":"https://github.com/shinnn/restore-npm-cache","last_synced_at":"2025-06-20T23:06:42.043Z","repository":{"id":57355125,"uuid":"152729056","full_name":"shinnn/restore-npm-cache","owner":"shinnn","description":"Restore contents from an npm cache","archived":false,"fork":false,"pushed_at":"2018-12-05T23:27:22.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-06T07:49:04.736Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shinnn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-12T09:43:30.000Z","updated_at":"2018-12-05T23:27:23.000Z","dependencies_parsed_at":"2022-08-28T13:20:31.857Z","dependency_job_id":null,"html_url":"https://github.com/shinnn/restore-npm-cache","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/shinnn/restore-npm-cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Frestore-npm-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Frestore-npm-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Frestore-npm-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Frestore-npm-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shinnn","download_url":"https://codeload.github.com/shinnn/restore-npm-cache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Frestore-npm-cache/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261032037,"owners_count":23100048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-18T17:34:49.488Z","updated_at":"2025-06-20T23:06:37.033Z","avatar_url":"https://github.com/shinnn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# restore-npm-cache\n\n[![npm version](https://img.shields.io/npm/v/restore-npm-cache.svg)](https://www.npmjs.com/package/restore-npm-cache)\n[![Build Status](https://travis-ci.com/shinnn/restore-npm-cache.svg?branch=master)](https://travis-ci.com/shinnn/restore-npm-cache)\n[![Coverage Status](https://img.shields.io/coveralls/shinnn/restore-npm-cache.svg)](https://coveralls.io/github/shinnn/restore-npm-cache?branch=master)\n\nRestore contents from an [npm](https://docs.npmjs.com/getting-started/what-is-npm) [cache](https://docs.npmjs.com/cli/cache#details)\n\n```javascript\nconst restoreNpmCache = require('restore-npm-cache');\n\n(async () =\u003e {\n  await restoreNpmCache('make-fetch-happen:request-cache:https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz');\n\n  require('./package/package.json');\n  //=\u003e {name: 'lodash', version: '4.17.10', description: 'Lodash modular utilities.', ...}\n})();\n```\n\n## Installation\n\n[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm).\n\n```\nnpm install restore-npm-cache\n```\n\n## API\n\n```javascript\nconst restoreNpmCache = require('restore-npm-cache');\n```\n\n### restoreNpmCache(*key* [, *options*])\n\n*key*: `string`  \n*options*: `Object` ([node-tar](https://github.com/npm/node-tar)'s [`Unpack`](https://github.com/npm/node-tar#class-tarunpack) constructor options with `strict` defaulting to `true`)  \nReturn: `Promise\u003cObject\u003e`\n\nIt finds an npm cache entry identified by the given key, extract its contents from the gzipped tarball to a directory where `cwd` option points (or `process.cwd()` if `cwd` is not provided), and returns a `Promise` for [information of the entry](https://github.com/zkat/cacache#--cacachegetinfocache-key---promise).\n\nIt automatically creates directories when the directory specified by `cwd` option doesn't exist.\n\n```javascript\nconst {readdir} = require('fs').promises;\nconst restoreNpmCache = require('restore-npm-cache');\n\n(async () =\u003e {\n  const info = await restoreNpmCache('make-fetch-happen:request-cache:https://registry.npmjs.org/eslint/-/eslint-5.6.1.tgz', {\n    cwd: 'new/dir',\n    strip: 1\n  });\n\n  info.integrity; //=\u003e 'sha512-hgrDtGWz368b7Wqf+ ... 5WRN1TAS6eo7AYA=='\n  info.size; //=\u003e 514066\n  info.time; //=\u003e 538368647819\n\n  await readdir('new/dir');\n  /*=\u003e [\n    'CHANGELOG.md',\n    'LICENSE',\n    'README.md',\n    'bin',\n    'conf',\n    'lib',\n    'messages',\n    'package.json'\n  ] */\n})();\n```\n\n## License\n\n[ISC License](./LICENSE) © 2018 Shinnosuke Watanabe\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Frestore-npm-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinnn%2Frestore-npm-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Frestore-npm-cache/lists"}