@@ -61,12 +61,6 @@ export async function run(
61
61
let range ;
62
62
reporter . step ( ++ step , totalSteps , `Removing module ${ name } ` ) ;
63
63
64
- // remove bins
65
- let pkg = await config . readManifest ( loc ) ;
66
- for ( let binName in pkg . bin ) {
67
- await fs . unlink ( path . join ( config . modulesFolder , "node_modules" , ".bin" , binName ) ) ;
68
- }
69
-
70
64
// remove from `package.json`
71
65
for ( let type of [ "devDependencies" , "dependencies" , "optionalDependencies" ] ) {
72
66
let deps = json [ type ] ;
@@ -75,27 +69,31 @@ export async function run(
75
69
delete deps [ name ] ;
76
70
}
77
71
}
72
+ if ( ! range ) {
73
+ throw new MessageError ( "This module isn't specified in package.json" ) ;
74
+ }
75
+
76
+ // remove bins
77
+ let pkg = await config . readManifest ( loc ) ;
78
+ for ( let binName in pkg . bin ) {
79
+ await fs . unlink ( path . join ( config . modulesFolder , "node_modules" , ".bin" , binName ) ) ;
80
+ }
78
81
79
82
// remove entire package
80
83
let locs = [ ] ;
81
- if ( range ) {
82
- // add all transitive dependencies locations
83
- addSub ( `${ name } @${ range } ` ) ;
84
84
85
- function addSub ( pattern ) {
86
- let pkg = install . resolver . getResolvedPattern ( pattern ) ;
87
- if ( ! pkg ) return ; // TODO could possibly throw an error?
85
+ // add all transitive dependencies locations
86
+ addSub ( `${ name } @${ range } ` ) ;
87
+
88
+ function addSub ( pattern ) {
89
+ let pkg = install . resolver . getResolvedPattern ( pattern ) ;
90
+ if ( ! pkg ) return ; // TODO could possibly throw an error?
88
91
89
- locs . push ( config . generateHardModulePath ( pkg . reference ) ) ;
92
+ locs . push ( config . generateHardModulePath ( pkg . reference ) ) ;
90
93
91
- for ( let key in pkg . dependencies ) {
92
- addSub ( `${ key } @${ pkg . dependencies [ key ] } ` ) ;
93
- }
94
+ for ( let key in pkg . dependencies ) {
95
+ addSub ( `${ key } @${ pkg . dependencies [ key ] } ` ) ;
94
96
}
95
- } else {
96
- // doesn't look like this was in package.json so we don't have a pattern to seed
97
- // the search
98
- locs. push ( loc ) ;
99
97
}
100
98
101
99
for ( let loc of locs ) {
0 commit comments