Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdel El-Medny committed Feb 5, 2019
2 parents 4f28547 + ebba7a1 commit b42da7d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": "0.2.0",
"configurations": [
{
"type": "node",
"type": "node2",
"request": "attach",
"name": "Node: Nodemon-attach",
"protocol": "inspector",
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-translate-merge",
"version": "1.0.3",
"version": "1.0.4",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
23 changes: 13 additions & 10 deletions src/analyzer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as pluralize from 'pluralize';
import { ITranslationDifference, ITranslationFile } from '../types';
import { IConfiguration, ITranslationDifference } from '../types';

export class Analyzer {

Expand All @@ -23,12 +23,9 @@ export class Analyzer {
return differences;
}

logDifferences(
differences: Map<string, ITranslationDifference>,
fixFlagOn: boolean
) {
createFeedback( differences: Map<string, ITranslationDifference> ): string[] {

const message: string[] = [];
const messages: string[] = [];

/** We want to be positive here! So we will show the good news first */
const positivelySortedDifferences = Array.from(differences.entries()).sort((a, b) => {
Expand Down Expand Up @@ -62,14 +59,20 @@ export class Analyzer {
toAppendMessage = `🎉 '${fileKey}' matches the master file`;
}

message.push(toAppendMessage);
messages.push(toAppendMessage);
});

console.log(message.join('\n'));

return messages;
}

handleFeedback(messages: string[], config: IConfiguration) {
console.log(messages.join('\n'));

if (fixFlagOn === false) {
if (config.autoFix === false) {
console.log('\x1b[32m%s\x1b[0m', `To fix this, run the command with the --autofix flag or add autofix to true in the configuration file`);
return null;
} else {
return messages;
}
}

Expand Down
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ export class Main {

const differences = this.analyzer.getDifferences(configuration!.masterFileName, translationsMap!);

this.analyzer.logDifferences(differences, configuration!.autoFix);
const messages = this.analyzer.createFeedback(differences)!;

this.analyzer.handleFeedback(messages, configuration!);

if ( configuration!.autoFix ) {
const fixedFilesMap = this.translationsDifferenceHandler.handle(
translationsMap!,
Expand All @@ -55,6 +57,11 @@ export class Main {
configuration!,
'json'
);

this.filesManager.writeFile(
configuration!.i18nFilesPath + '/fixed/summary.txt',
messages.join('\n')
);
}

spinner.stop();
Expand Down

0 comments on commit b42da7d

Please sign in to comment.