@@ -113,6 +113,14 @@ export abstract class BaseGenerator<TStep extends string> extends generator {
113113 }
114114 }
115115
116+ mergeAnswers ( ) : void {
117+ if ( this . sharedOptions === undefined ) {
118+ return ;
119+ }
120+
121+ _ . merge ( this . answers , this . sharedOptions . values ) ;
122+ }
123+
116124 setRootPath ( rootPath ?: string ) : void {
117125
118126 if ( this . sharedOptions === undefined || this . sharedOptions . rootPath === undefined ) {
@@ -373,6 +381,8 @@ export abstract class BaseGenerator<TStep extends string> extends generator {
373381 async copyTemplateFiles ( ) : Promise < void > {
374382 if ( this . skipGenerator ) return ;
375383
384+ this . mergeAnswers ( ) ;
385+
376386 this . conflictedProjectFiles = new Project ( this . projectInfo ) ;
377387
378388 this . projectFiles . templateFiles . forEach ( file => {
@@ -401,12 +411,12 @@ export abstract class BaseGenerator<TStep extends string> extends generator {
401411 const addJsonFileContent = fs . readFileSync ( file . filePath , 'utf-8' ) ;
402412 const addJsonContent = JSON . parse ( addJsonFileContent ) ;
403413
404- _ . mergeWith ( newJsonContent , existingJsonContent , ( objValue , srcValue ) => {
414+ _ . mergeWith ( newJsonContent , addJsonContent , ( objValue , srcValue ) => {
405415 if ( _ . isArray ( objValue ) ) {
406416 return objValue . concat ( srcValue ) ;
407417 }
408418 } ) ;
409- _ . mergeWith ( newJsonContent , addJsonContent , ( objValue , srcValue ) => {
419+ _ . mergeWith ( newJsonContent , existingJsonContent , ( objValue , srcValue ) => {
410420 if ( _ . isArray ( objValue ) ) {
411421 return objValue . concat ( srcValue ) ;
412422 }
@@ -424,6 +434,7 @@ export abstract class BaseGenerator<TStep extends string> extends generator {
424434 case '.txt' :
425435 case '.md' :
426436 case '.gitignore' :
437+ case '.npmignore' :
427438 const newGitContent = fs . readFileSync ( file . filePath , 'utf-8' ) ;
428439 const gitContent = this . fs . read ( this . destinationPath ( file . targetPath ) , 'utf-8' ) ;
429440 const newFileContent = `${ gitContent } \n\n# ${ this . generatorName } related:\n${ newGitContent } ` ;
0 commit comments