* The `_restoreLinks` method restores the dependencies from the internal * `PackageCache` metadata so that the manifest matches its original state after * performing the links. * * It is also responsible for restoring these links into the `PackageCache`. * * @private * @method _
(label, type)
| 426 | * @param {String} type The type of package cache. |
| 427 | */ |
| 428 | _restoreLinks(label, type) { |
| 429 | let cachedManifest = this._readManifest(label, type); |
| 430 | if (!cachedManifest) { |
| 431 | return; |
| 432 | } |
| 433 | |
| 434 | let jsonManifest = JSON.parse(cachedManifest); |
| 435 | let links = jsonManifest._packageCache.links; |
| 436 | |
| 437 | // Blindly restore links. |
| 438 | let link, linkPath; |
| 439 | for (let i = 0; i < links.length; i++) { |
| 440 | link = links[i]; |
| 441 | if (typeof link === 'string') { |
| 442 | commands[type].invoke('link', link, { cwd: this.dirs[label] }); |
| 443 | } else { |
| 444 | linkPath = path.join(this.dirs[label], translate(type, 'path'), link.name); |
| 445 | fs.mkdirsSync(path.dirname(linkPath)); // Just in case the path doesn't exist. |
| 446 | symlinkOrCopySync(link.path, linkPath); |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | // Restore to original state. |
| 451 | let keys = Object.keys(jsonManifest._packageCache.originals); |
| 452 | let key; |
| 453 | for (let i = 0; i < keys.length; i++) { |
| 454 | key = keys[i]; |
| 455 | jsonManifest[key] = jsonManifest._packageCache.originals[key]; |
| 456 | } |
| 457 | |
| 458 | // Get rid of the originals. |
| 459 | delete jsonManifest._packageCache.originals; |
| 460 | |
| 461 | // Serialize back to disk. |
| 462 | let manifest = JSON.stringify(jsonManifest); |
| 463 | this._writeManifest(label, type, manifest); |
| 464 | } |
| 465 | |
| 466 | /** |
| 467 | * The `_checkManifest` method compares the desired manifest to that which |
no test coverage detected