@@ -61,14 +61,12 @@ module.exports = class ServiceGenerator extends ArtifactGenerator {
61
61
async checkPaths ( ) {
62
62
// check for datasources
63
63
if ( ! fs . existsSync ( this . artifactInfo . datasourcesDir ) ) {
64
- return this . exit (
65
- new Error (
66
- `${ ERROR_NO_DATA_SOURCES_FOUND } ${
67
- this . artifactInfo . datasourcesDir
68
- } .${ chalk . yellow (
69
- 'Please visit https://loopback.io/doc/en/lb4/DataSource-generator.html for information on how datasources are discovered' ,
70
- ) } `,
71
- ) ,
64
+ new Error (
65
+ `${ ERROR_NO_DATA_SOURCES_FOUND } ${
66
+ this . artifactInfo . datasourcesDir
67
+ } . ${ chalk . yellow (
68
+ 'Please visit https://loopback.io/doc/en/lb4/DataSource-generator.html for information on how datasources are discovered' ,
69
+ ) } `,
72
70
) ;
73
71
}
74
72
}
@@ -142,7 +140,7 @@ module.exports = class ServiceGenerator extends ArtifactGenerator {
142
140
new Error (
143
141
`${ ERROR_NO_DATA_SOURCES_FOUND } ${
144
142
this . artifactInfo . datasourcesDir
145
- } .${ chalk . yellow (
143
+ } . ${ chalk . yellow (
146
144
'Please visit https://loopback.io/doc/en/lb4/DataSource-generator.html for information on how datasources are discovered' ,
147
145
) } `,
148
146
) ,
@@ -223,10 +221,9 @@ module.exports = class ServiceGenerator extends ArtifactGenerator {
223
221
path . join ( this . artifactInfo . outDir , this . artifactInfo . outFile ) ,
224
222
) ;
225
223
226
- if ( debug . enabled ) {
227
- debug ( `artifactInfo: ${ inspect ( this . artifactInfo ) } ` ) ;
228
- debug ( `Copying artifact to: ${ dest } ` ) ;
229
- }
224
+ debug ( `artifactInfo: ${ inspect ( this . artifactInfo ) } ` ) ;
225
+ debug ( `Copying artifact to: ${ dest } ` ) ;
226
+
230
227
this . fs . copyTpl (
231
228
source ,
232
229
dest ,
@@ -237,6 +234,19 @@ module.exports = class ServiceGenerator extends ArtifactGenerator {
237
234
return ;
238
235
}
239
236
237
+ install ( ) {
238
+ if ( this . shouldExit ( ) ) return false ;
239
+ debug ( 'install npm dependencies' ) ;
240
+ const pkgJson = this . packageJson || { } ;
241
+ const deps = pkgJson . dependencies || { } ;
242
+ const pkgs = [ ] ;
243
+
244
+ if ( ! deps [ '@loopback/service-proxy' ] ) {
245
+ pkgs . push ( '@loopback/service-proxy' ) ;
246
+ }
247
+ if ( pkgs . length ) this . npmInstall ( pkgs , { save : true } ) ;
248
+ }
249
+
240
250
async end ( ) {
241
251
await super . end ( ) ;
242
252
}
0 commit comments