@@ -18,7 +18,8 @@ import * as constants from "../../constants.js";
18
18
import * as fs from "../../util/fs.js" ;
19
19
import * as util from "../../util/misc.js" ;
20
20
21
- let path = require ( "path" ) ;
21
+ let semver = require ( "semver" ) ;
22
+ let path = require ( "path" ) ;
22
23
23
24
export let noArguments = true ;
24
25
@@ -80,10 +81,37 @@ export async function run(
80
81
// check if any of the node_modules are out of sync
81
82
let res = await install . linker . initCopyModules ( rawPatterns ) ;
82
83
for ( let [ loc ] of res ) {
84
+ let human = path . relative ( path . join ( process . cwd ( ) , "node_modules" ) , loc ) ;
85
+ human = human . replace ( / n o d e _ m o d u l e s / g, " > " ) ;
86
+
83
87
if ( ! ( await fs . exists ( loc ) ) ) {
84
- reporter . error ( `Module not installed: ${ path . relative ( process . cwd ( ) , loc ) } ` ) ;
88
+ reporter . error ( `Module not installed: ${ human } ` ) ;
85
89
valid = false ;
86
90
}
91
+
92
+ let pkg = await fs . readJson ( path . join ( loc , "package.json" ) ) ;
93
+
94
+ let deps = Object . assign ( { } , pkg . dependencies , pkg . devDependencies , pkg . peerDependencies ) ;
95
+
96
+ for ( let name in deps ) {
97
+ let range = deps [ name ] ;
98
+ if ( ! semver . validRange ( range ) ) continue ; // exotic
99
+
100
+ let depPkgLoc = path . join ( loc , "node_modules" , name , "package.json" ) ;
101
+ if ( ! ( await fs . exists ( depPkgLoc ) ) ) {
102
+ // we'll hit the module not install error above when this module is hit
103
+ continue ;
104
+ }
105
+
106
+ let depPkg = await fs . readJson ( depPkgLoc ) ;
107
+ if ( semver . satisfies ( depPkg . version , range ) ) continue ;
108
+
109
+ // module isn't correct semver
110
+ reporter . error (
111
+ `Module ${ human } depends on ${ name } with the range ${ range } but it doesn't match the ` +
112
+ `installed version of ${ depPkg . version } `
113
+ ) ;
114
+ }
87
115
}
88
116
}
89
117
0 commit comments