Moved splitBundle to utils and set optional to additionalBuffers

This commit is contained in:
Alexander Cerutti
2019-07-10 00:24:53 +02:00
parent 6d39139dc7
commit f4dabb42b0
2 changed files with 19 additions and 17 deletions

View File

@@ -1,5 +1,6 @@
import moment from "moment";
import { EOL } from "os";
import { BundleUnit } from "./schema";
/**
* Checks if an rgb value is compliant with CSS-like syntax
@@ -80,3 +81,18 @@ export function generateStringFile(lang: { [index: string]: string }): Buffer {
return Buffer.from(strings.join(EOL), "utf8");
}
/**
* Applies a partition to split one bundle
* to two
* @param origin
*/
export function splitBundle(origin: Object): [BundleUnit, BundleUnit] {
const keys = Object.keys(origin);
return keys.reduce(([ l10n, bundle ], current) =>
current.includes(".lproj") &&
[ { ...l10n, [current]: origin[current] }, bundle] ||
[ l10n, {...bundle, [current]: origin[current] }]
, [{},{}]);
}