Skip to content

Commit 2c244ed

Browse files
author
Peter Ullrich
committed
mergeAnswers
1 parent 2dcfefb commit 2c244ed

File tree

4 files changed

+28
-142
lines changed

4 files changed

+28
-142
lines changed

package-lock.json

Lines changed: 11 additions & 137 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.4.2",
2+
"version": "0.4.3",
33
"name": "dotup-typescript-yeoman-generators",
44
"author": {
55
"name": "Peter Ullrich",
@@ -25,7 +25,7 @@
2525
"chalk": "^2.4.2"
2626
},
2727
"devDependencies": {
28-
"@types/yeoman-generator": "2.0.3",
28+
"@types/yeoman-generator": "3.1.1",
2929
"@types/lodash": "^4.14.123",
3030
"@types/chai": "^4.1.7",
3131
"@types/mocha": "^5.2.6",

src/BaseGenerator.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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}`;

src/project/ProjectType.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export enum ProjectType {
22
app = 'app',
3-
lib = 'lib'
3+
lib = 'lib',
4+
blank = 'blank'
45
}

0 commit comments

Comments
 (0)