Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
has-modern-meta: git deps do not need shasum or integrity
Browse files Browse the repository at this point in the history
  • Loading branch information
iarna committed Feb 20, 2018
1 parent 9936cf5 commit 857dab0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 30 deletions.
8 changes: 6 additions & 2 deletions lib/install/has-modern-meta.js
@@ -1,15 +1,19 @@
'use strict'
module.exports = hasModernMeta

const npa = require('npm-package-arg')
const moduleName = require('../utils/module-name.js')

function isLink (child) {
return child.isLink || (child.parent && isLink(child.parent))
}

function hasModernMeta (child) {
if (!child) return false
const resolved = child.package._resolved && npa.resolve(moduleName(child), child.package._resolved)
return child.isTop || isLink(child) || (
child.package &&
child.package._resolved &&
(child.package._integrity || child.package._shasum)
resolved &&
(child.package._integrity || child.package._shasum || resolved.type === 'git')
)
}
4 changes: 4 additions & 0 deletions test/tap/override-bundled.js
Expand Up @@ -65,6 +65,8 @@ var bundlekeepjson = {
_requested: {
rawSpec: bundlekeeptgz
},
_resolved: bundlekeeptgz,
_shasum: 'baadf00d',
files: ['OLD', 'NEW']

}
Expand All @@ -77,6 +79,8 @@ var bundledeepjson = {
_requested: {
rawSpec: bundledeeptgz
},
_resolved: bundlekeeptgz,
_shasum: 'deadbeef',
files: ['OLD', 'NEW']

}
Expand Down
30 changes: 2 additions & 28 deletions test/tap/tagged-version-matching.js
Expand Up @@ -46,24 +46,6 @@ var fixture = new Tacks(Dir({
'package.json': File({
_from: 'npm/example-gitdep',
_id: 'gitdep@1.0.0',
_requested: {
raw: 'gitdep@git://github.com/npm/example-gitdep.git#da39a3ee5e6b4b0d3255bfef95601890afd80709',
scope: null,
escapedName: 'gitdep',
name: 'gitdep',
rawSpec: 'git://github.com/npm/example-gitdep.git#da39a3ee5e6b4b0d3255bfef95601890afd80709',
spec: 'git://github.com/npm/example-gitdep.git#da39a3ee5e6b4b0d3255bfef95601890afd80709',
type: 'hosted',
hosted: {
type: 'github',
ssh: 'git@github.com:npm/example-gitdep.git#da39a3ee5e6b4b0d3255bfef95601890afd80709',
sshUrl: 'git+ssh://git@github.com/npm/example-gitdep.git#da39a3ee5e6b4b0d3255bfef95601890afd80709',
httpsUrl: 'git+https://github.com/npm/example-gitdep.git#da39a3ee5e6b4b0d3255bfef95601890afd80709',
gitUrl: 'git://github.com/npm/example-gitdep.git#da39a3ee5e6b4b0d3255bfef95601890afd80709',
shortcut: 'github:npm/example-gitdep#da39a3ee5e6b4b0d3255bfef95601890afd80709',
directUrl: 'https://raw.githubusercontent.com/npm/example-gitdep/da39a3ee5e6b4b0d3255bfef95601890afd80709/package.json'
}
},
_resolved: 'github:npm/example-gitdep#da39a3ee5e6b4b0d3255bfef95601890afd80709',
name: 'gitdep',
version: '1.0.0'
Expand All @@ -74,15 +56,7 @@ var fixture = new Tacks(Dir({
_from: 'tagdep@latest',
_id: 'tagdep@1.0.0',
_integrity: 'sha1-0EJSKmsdk39848LlrRg/hZQo2B8=',
_requested: {
raw: 'tagdep@https://registry.example.com/tagdep/-/tagdep-1.0.0.tgz',
scope: null,
escapedName: 'tagdep',
name: 'tagdep',
rawSpec: 'https://registry.example.com/tagdep/-/tagdep-1.0.0.tgz',
spec: 'https://registry.example.com/tagdep/-/tagdep-1.0.0.tgz',
type: 'remote'
},
_resolved: 'https://registry.example.com/tagdep/-/tagdep-1.0.0.tgz',
name: 'tagdep',
version: '1.0.0'
})
Expand All @@ -102,7 +76,7 @@ var fixture = new Tacks(Dir({
example: {
version: 'file:example',
requires: {
tagdep: '1.0.0',
tagdep: '^1.0.0',
gitdep: 'github:npm/example-gitdep#da39a3ee5e6b4b0d3255bfef95601890afd80709'
}
},
Expand Down

0 comments on commit 857dab0

Please sign in to comment.