From bf9262c35171a1348f6ce00c1b3f80f95c445fd8 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 28 Aug 2021 17:37:20 +0300 Subject: [PATCH] Remove empty arrays --- index.js | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 2fa82f2..491f76e 100644 --- a/index.js +++ b/index.js @@ -79,7 +79,11 @@ module.exports = function(babel) delete strings[path.hub.file.opts.filename]; const arrays = { ...strings }; for (let k in arrays) + { arrays[k] = Object.keys(arrays[k]); + if (!arrays[k].length) + delete arrays[k]; + } fs.writeFileSync( path.hub.file.opts.root+'/'+(state.opts['output'] || 'react-translate-output.json'), JSON.stringify(arrays, null, 2) diff --git a/package.json b/package.json index a9c9bd3..2e1a39a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "babel-plugin-react-translate", - "version": "1.0.1", + "version": "1.0.2", "description": "Babel-based JS/JSX auto-translator for Russian language", "main": "index.js", "scripts": {