From 25d5526c8995443b03c113c44f9c8e9a79c2c074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Mon, 30 Sep 2019 13:31:01 +0200 Subject: [PATCH] Use different folders with integrity or without (#7586) * Uses a different folder for pkgs with integrity or without * Fixes for when integrity is an object instance * Stores whether integrity exists or not * Updates a lockfile to reference the integrity * Fixes resolver check * Fixes cache pattern --- __tests__/fixtures/install/install-production/yarn.lock | 2 ++ __tests__/package-resolver.js | 2 +- src/config.js | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/__tests__/fixtures/install/install-production/yarn.lock b/__tests__/fixtures/install/install-production/yarn.lock index 83f2533fdc..0d7972c07f 100644 --- a/__tests__/fixtures/install/install-production/yarn.lock +++ b/__tests__/fixtures/install/install-production/yarn.lock @@ -5,7 +5,9 @@ is-array@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-array/-/is-array-1.0.1.tgz#e9850cc2cc860c3bc0977e84ccf0dd464584279a" + integrity sha1-6YUMwsyGDDvAl36EzPDdRkWEJ5o= left-pad@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.1.3.tgz#612f61c033f3a9e08e939f1caebeea41b6f3199a" + integrity sha1-YS9hwDPzqeCOk58crr7qQbbzGZo= diff --git a/__tests__/package-resolver.js b/__tests__/package-resolver.js index 269c1b614d..3c0ff6c485 100644 --- a/__tests__/package-resolver.js +++ b/__tests__/package-resolver.js @@ -14,7 +14,7 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000; const path = require('path'); // regexp which verifies that the cache path contains a path component ending with semver + hash -const cachePathRe = /-\d+\.\d+\.\d+-[\dabcdef]{40}[\\\/]/; +const cachePathRe = /-\d+\.\d+\.\d+-[\dabcdef]{40}(?:-integrity)?[\\\/]/; async function createEnv(configOptions): Object { const lockfile = new Lockfile(); diff --git a/src/config.js b/src/config.js index 2fdf5ff162..caf3d247af 100644 --- a/src/config.js +++ b/src/config.js @@ -17,6 +17,7 @@ import {registries, registryNames} from './registries/index.js'; import {NoopReporter} from './reporters/index.js'; import map from './util/map.js'; +const crypto = require('crypto'); const detectIndent = require('detect-indent'); const invariant = require('invariant'); const path = require('path'); @@ -520,6 +521,10 @@ export default class Config { slug += `-${hash}`; } + if (pkg.remote.integrity) { + slug += `-integrity`; + } + return slug; }