* The `create` method adds a new package cache entry. * * @method create * @param {String} label The label for the cache. * @param {String} type The type of package cache. * @param {String} manifest The contents of the manifest file for the cache. * @param {Array} links Packages to
(label, type, manifest, links)
| 569 | * @return {String} The directory on disk which contains the cache. |
| 570 | */ |
| 571 | create(label, type, manifest, links) { |
| 572 | links = links || []; |
| 573 | |
| 574 | // Save metadata about the PackageCache invocation in the manifest. |
| 575 | let packageManagerVersion = commands[type].invoke('--version').stdout; |
| 576 | |
| 577 | let jsonManifest = JSON.parse(manifest); |
| 578 | jsonManifest._packageCache = { |
| 579 | node: process.version, |
| 580 | packageManager: type, |
| 581 | packageManagerVersion, |
| 582 | links, |
| 583 | }; |
| 584 | |
| 585 | manifest = JSON.stringify(jsonManifest); |
| 586 | |
| 587 | // Compare any existing manifest to the ideal per current blueprint. |
| 588 | let identical = this._checkManifest(label, type, manifest); |
| 589 | |
| 590 | if (identical) { |
| 591 | // Use what we have, but opt in to SemVer drift. |
| 592 | this._upgrade(label, type); |
| 593 | } else { |
| 594 | // Tell the package manager to start semi-fresh. |
| 595 | this._writeManifest(label, type, manifest); |
| 596 | this._install(label, type); |
| 597 | } |
| 598 | |
| 599 | return this.dirs[label]; |
| 600 | } |
| 601 | |
| 602 | /** |
| 603 | * The `update` method aliases the `create` method. |
no test coverage detected