prefetch-yarn-deps: Fix parsing of scoped packages

+23 -3
+10 -3
pkgs/build-support/node/fetch-yarn-deps/index.js
··· 88 88 } 89 89 90 90 const downloadPkg = (pkg, verbose) => { 91 - const [ name, spec ] = pkg.key.split('@', 2); 92 - if (spec.startsWith('file:')) { 93 - console.info(`ignoring relative file:path dependency "${spec}"`) 91 + const fileMarker = '@file:' 92 + const split = pkg.key.split(fileMarker) 93 + if (split.length == 2) { 94 + console.info(`ignoring lockfile entry "${split[0]}" which points at path "${split[1]}"`) 94 95 return 96 + } else if (split.length > 2) { 97 + throw new Error(`The lockfile entry key "${pkg.key}" contains "${fileMarker}" more than once. Processing is not implemented.`) 98 + } 99 + 100 + if (pkg.resolved === undefined) { 101 + throw new Error(`The lockfile entry with key "${pkg.key}" cannot be downloaded because it is missing the "resolved" attribute, which should contain the URL to download from. The lockfile might be invalid.`) 95 102 } 96 103 97 104 const [ url, hash ] = pkg.resolved.split('#')
+4
pkgs/build-support/node/fetch-yarn-deps/tests/default.nix
··· 1 1 { testers, fetchYarnDeps, ... }: 2 2 3 3 { 4 + file = testers.invalidateFetcherByDrvHash fetchYarnDeps { 5 + yarnLock = ./file.lock; 6 + sha256 = "sha256-BPuyQVCbdpFL/iRhmarwWAmWO2NodlVCOY9JU+4pfa4="; 7 + }; 4 8 simple = testers.invalidateFetcherByDrvHash fetchYarnDeps { 5 9 yarnLock = ./simple.lock; 6 10 sha256 = "sha256-FRrt8BixleILmFB2ZV8RgPNLqgS+dlH5nWoPgeaaNQ8=";
+9
pkgs/build-support/node/fetch-yarn-deps/tests/file.lock
··· 1 + # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 + # yarn lockfile v1 3 + 4 + 5 + "@org/somepack@file:vendor/orgpacks/somepack/assets": 6 + version "1.0.0" 7 + 8 + "otherpack@file:vendor/otherpack": 9 + version "1.0.0"