locize-cli
Advanced tools
Comparing version 3.3.1 to 3.4.0
@@ -16,4 +16,6 @@ const colors = require('colors'); | ||
var data = {}; | ||
data[opt.key] = opt.value || null; // null will remove the key | ||
var data = opt.data || {}; | ||
if (!opt.data) { | ||
data[opt.key] = opt.value || null; // null will remove the key | ||
} | ||
@@ -20,0 +22,0 @@ request({ |
@@ -0,1 +1,4 @@ | ||
## 3.4.0 | ||
- add possibility to skip-empty namespaces | ||
## 3.3.1 | ||
@@ -2,0 +5,0 @@ - sort keys for flat json export |
@@ -15,2 +15,4 @@ const colors = require('colors'); | ||
if (opt.skipEmpty === undefined) opt.skipEmpty = true; | ||
var url = opt.apiPath + '/download/' + opt.projectId; | ||
@@ -88,2 +90,20 @@ | ||
(cb) => { | ||
if (opt.format !== 'json' || !opt.skipEmpty) return cb(); | ||
async.forEach(localFiles, (f, cb) => { | ||
fs.readFile(f.pathToLocalFile, 'utf8', (err, data) => { | ||
if (err) return cb(err); | ||
try { | ||
const parsedData = JSON.parse(data); | ||
if (Object.keys(parsedData).length === 0) { | ||
fs.unlink(f.pathToLocalFile, cb); | ||
} else { | ||
cb(); | ||
} | ||
} catch (err) { | ||
cb(err); | ||
} | ||
}); | ||
}, cb); | ||
}, | ||
(cb) => { | ||
if (opt.format !== 'flat') return cb(); | ||
@@ -95,2 +115,5 @@ async.forEach(localFiles, (f, cb) => { | ||
const flatted = flatten(JSON.parse(data)); | ||
if (opt.skipEmpty && Object.keys(flatted).length === 0) { | ||
return fs.unlink(f.pathToLocalFile, cb); | ||
} | ||
var sorted = {}; | ||
@@ -114,2 +137,5 @@ Object.keys(flatted).sort().forEach((k) => sorted[k] = flatted[k]); | ||
const js = flatten(JSON.parse(data)); | ||
if (opt.skipEmpty && Object.keys(js).length === 0) { | ||
return fs.unlink(f.pathToLocalFile, cb); | ||
} | ||
js2asr(js, (err, res) => { | ||
@@ -165,2 +191,6 @@ if (err) return cb(err); | ||
if (opt.skipEmpty && Object.keys(js).length === 0) { | ||
return fs.unlink(f.pathToLocalFile, cb); | ||
} | ||
const js2CsvData = Object.keys(js).reduce((mem, k) => { | ||
@@ -248,2 +278,5 @@ const refItem = refNs[k]; | ||
const js = flatten(JSON.parse(data)); | ||
if (opt.skipEmpty && Object.keys(js).length === 0) { | ||
return fs.unlink(f.pathToLocalFile, cb); | ||
} | ||
fn( | ||
@@ -250,0 +283,0 @@ opt.referenceLanguage, |
{ | ||
"name": "locize-cli", | ||
"version": "3.3.1", | ||
"version": "3.4.0", | ||
"description": "locize cli to import locales", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
38813
550