From 890ae5fba1010e1ddff6636b7c3044476ab702b9 Mon Sep 17 00:00:00 2001 From: Justin Bay Date: Sat, 22 Oct 2016 20:49:55 -0400 Subject: [PATCH] fix failure message when only adding/removing one key --- package.json | 2 +- src/ActionRecorder.ts | 4 +-- .../__snapshots__/runner.js.snap | 10 ++++---- .../options.ts | 0 .../project/locales/de.json | 0 .../project/locales/en.json | 0 .../project/locales/pt-BR.json | 0 .../__snapshots__/runner.js.snap | 25 +++++++++++++++++++ .../check-adds-removes-single-key/options.ts | 5 ++++ .../project/locales/de.json | 3 +++ .../project/locales/en.json | 4 +++ 11 files changed, 45 insertions(+), 8 deletions(-) rename tests/{adds-removes-keys-report => check-adds-removes-keys}/__snapshots__/runner.js.snap (63%) rename tests/{adds-removes-keys-report => check-adds-removes-keys}/options.ts (100%) rename tests/{adds-removes-keys-report => check-adds-removes-keys}/project/locales/de.json (100%) rename tests/{adds-removes-keys-report => check-adds-removes-keys}/project/locales/en.json (100%) rename tests/{adds-removes-keys-report => check-adds-removes-keys}/project/locales/pt-BR.json (100%) create mode 100644 tests/check-adds-removes-single-key/__snapshots__/runner.js.snap create mode 100644 tests/check-adds-removes-single-key/options.ts create mode 100644 tests/check-adds-removes-single-key/project/locales/de.json create mode 100644 tests/check-adds-removes-single-key/project/locales/en.json diff --git a/package.json b/package.json index 30b861a..8acefbd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "i18next-json-sync", - "version": "1.2.0-alpha2", + "version": "1.2.0", "description": "keep i18next json resource files in sync", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/src/ActionRecorder.ts b/src/ActionRecorder.ts index 144ef5d..d234132 100644 --- a/src/ActionRecorder.ts +++ b/src/ActionRecorder.ts @@ -22,8 +22,8 @@ export default class ActionRecorder { public hasAnyActions() { return this.hasAnyErrors() || - this.addedKeys.length > 1 || - this.removedKeys.length > 1; + this.addedKeys.length > 0 || + this.removedKeys.length > 0; } public flushToConsole() { diff --git a/tests/adds-removes-keys-report/__snapshots__/runner.js.snap b/tests/check-adds-removes-keys/__snapshots__/runner.js.snap similarity index 63% rename from tests/adds-removes-keys-report/__snapshots__/runner.js.snap rename to tests/check-adds-removes-keys/__snapshots__/runner.js.snap index 2391038..612f75a 100644 --- a/tests/adds-removes-keys-report/__snapshots__/runner.js.snap +++ b/tests/check-adds-removes-keys/__snapshots__/runner.js.snap @@ -1,25 +1,25 @@ -exports[`test adds-removes-keys-report:locales/de.json 1`] = ` +exports[`test check-adds-removes-keys:locales/de.json 1`] = ` "{ remove_de: remove, remove_de_too: remove also }" `; -exports[`test adds-removes-keys-report:locales/en.json 1`] = ` +exports[`test check-adds-removes-keys:locales/en.json 1`] = ` "{ add_me: add, keep_me: keep }" `; -exports[`test adds-removes-keys-report:locales/pt-BR.json 1`] = ` +exports[`test check-adds-removes-keys:locales/pt-BR.json 1`] = ` "{ keep_me: don\'t change, remove_me: remove }" `; -exports[`test adds-removes-keys-report:stderr.txt 1`] = ` +exports[`test check-adds-removes-keys:stderr.txt 1`] = ` " THROWN: Error: [i18next-json-sync] check failed -- keys are out of sync. Run again without check mode to synchronize files @@ -27,7 +27,7 @@ Error: [i18next-json-sync] check failed -- keys are out of sync. Run again witho " `; -exports[`test adds-removes-keys-report:stdout.txt 1`] = ` +exports[`test check-adds-removes-keys:stdout.txt 1`] = ` "Missing keys in actual/locales/de.json: add_me, keep_me Orphaned keys found in actual/locales/de.json: remove_de, remove_de_too Missing keys in actual/locales/pt-BR.json: add_me diff --git a/tests/adds-removes-keys-report/options.ts b/tests/check-adds-removes-keys/options.ts similarity index 100% rename from tests/adds-removes-keys-report/options.ts rename to tests/check-adds-removes-keys/options.ts diff --git a/tests/adds-removes-keys-report/project/locales/de.json b/tests/check-adds-removes-keys/project/locales/de.json similarity index 100% rename from tests/adds-removes-keys-report/project/locales/de.json rename to tests/check-adds-removes-keys/project/locales/de.json diff --git a/tests/adds-removes-keys-report/project/locales/en.json b/tests/check-adds-removes-keys/project/locales/en.json similarity index 100% rename from tests/adds-removes-keys-report/project/locales/en.json rename to tests/check-adds-removes-keys/project/locales/en.json diff --git a/tests/adds-removes-keys-report/project/locales/pt-BR.json b/tests/check-adds-removes-keys/project/locales/pt-BR.json similarity index 100% rename from tests/adds-removes-keys-report/project/locales/pt-BR.json rename to tests/check-adds-removes-keys/project/locales/pt-BR.json diff --git a/tests/check-adds-removes-single-key/__snapshots__/runner.js.snap b/tests/check-adds-removes-single-key/__snapshots__/runner.js.snap new file mode 100644 index 0000000..f88daad --- /dev/null +++ b/tests/check-adds-removes-single-key/__snapshots__/runner.js.snap @@ -0,0 +1,25 @@ +exports[`test check-adds-removes-single-key:locales/de.json 1`] = ` +"{ + keep_me: keep de +}" +`; + +exports[`test check-adds-removes-single-key:locales/en.json 1`] = ` +"{ + add_me: add, + keep_me: keep en +}" +`; + +exports[`test check-adds-removes-single-key:stderr.txt 1`] = ` +" +THROWN: +Error: [i18next-json-sync] check failed -- keys are out of sync. Run again without check mode to synchronize files + ... +" +`; + +exports[`test check-adds-removes-single-key:stdout.txt 1`] = ` +"Missing keys in actual/locales/de.json: add_me +" +`; diff --git a/tests/check-adds-removes-single-key/options.ts b/tests/check-adds-removes-single-key/options.ts new file mode 100644 index 0000000..f53dc6e --- /dev/null +++ b/tests/check-adds-removes-single-key/options.ts @@ -0,0 +1,5 @@ +import { IOptions } from '../../src'; +const options: IOptions = { + check: true +}; +export = options; \ No newline at end of file diff --git a/tests/check-adds-removes-single-key/project/locales/de.json b/tests/check-adds-removes-single-key/project/locales/de.json new file mode 100644 index 0000000..ad09f82 --- /dev/null +++ b/tests/check-adds-removes-single-key/project/locales/de.json @@ -0,0 +1,3 @@ +{ + "keep_me": "keep de" +} \ No newline at end of file diff --git a/tests/check-adds-removes-single-key/project/locales/en.json b/tests/check-adds-removes-single-key/project/locales/en.json new file mode 100644 index 0000000..071d5ea --- /dev/null +++ b/tests/check-adds-removes-single-key/project/locales/en.json @@ -0,0 +1,4 @@ +{ + "add_me": "add", + "keep_me": "keep en" +} \ No newline at end of file