diff --git a/API.md b/API.md
index 3d88106..c881aa7 100644
--- a/API.md
+++ b/API.md
@@ -60,7 +60,7 @@ ___
#### constructor()
```typescript
-const pass = await createPass({ ... });
+const pass = await createPass({ ... }, Buffer.from([ ... ]));
```
**Returns**:
@@ -71,15 +71,16 @@ const pass = await createPass({ ... });
| Key | Type | Description | Optional | Default Value |
|-----|------|---------------|:-------------:|:-----------:|
-| options | Object | The options to create the pass | false | -
-| options.model | String/Path/Buffer Object | The model path or a Buffer Object with path as key and Buffer as content | false | -
-| options.certificates | Object | The certificate object containing the paths to certs files. | false | -
-| options.certificates.wwdr | String/Path | The path to Apple WWDR certificate or its content. | false | -
-| options.certificates.signerCert | String/Path | The path to Developer certificate file or its content. | false | -
-| options.certificates.signerKey | Object/String | The object containing developer certificate's key and passphrase. If string, it can be the path to the key file or its content. If object, must have `keyFile` key and might need `passphrase`. | false | -
-| options.certificates.signerKey.keyFile | String/Path | The path to developer certificate key or its content. | false | -
-| options.certificates.signerKey.passphrase | String \| Number | The passphrase to use to unlock the key. | false | -
-| options.overrides | Object | Dictionary containing all the keys you can override in the pass.json file and does not have a method to get overridden. | true | { }
+| options | Object | The options to create the pass | `false` | -
+| options.model | String \| Path \| Buffer Object | The model path or a Buffer Object with path as key and Buffer as content | `false` | -
+| options.certificates | Object | The certificate object containing the paths to certs files. | `false` | -
+| options.certificates.wwdr | String \| Path | The path to Apple WWDR certificate or its content. | `false` | -
+| options.certificates.signerCert | String \| Path | The path to Developer certificate file or its content. | `false` | -
+| options.certificates.signerKey | Object/String | The object containing developer certificate's key and passphrase. If string, it can be the path to the key file or its content. If object, must have `keyFile` key and might need `passphrase`. | `false` | -
+| options.certificates.signerKey.keyFile | String \| Path | The path to developer certificate key or its content. | `false` | -
+| options.certificates.signerKey.passphrase | String \| Number | The passphrase to use to unlock the key. | `false` | -
+| options.overrides | Object | Dictionary containing all the keys you can override in the pass.json file and does not have a method to get overridden. | `true` | `{ }`
+| additionalBuffers | Buffer Object | Dictionary with path as key and Buffer as a content. Each will represent a file to be added to the final model. These will have priority on model ones | `true` | `{ }`
diff --git a/src/factory.ts b/src/factory.ts
index 7f34274..5949758 100644
--- a/src/factory.ts
+++ b/src/factory.ts
@@ -1,11 +1,11 @@
import { Pass } from "./pass";
-import { FactoryOptions } from "./schema";
+import { FactoryOptions, BundleUnit } from "./schema";
import formatMessage from "./messages";
import { getModelContents, readCertificatesFromOptions } from "./parser";
export type Pass = InstanceType
-export async function createPass(options: FactoryOptions): Promise {
+export async function createPass(options: FactoryOptions, additionalBuffers: BundleUnit): Promise {
if (!(options && Object.keys(options).length)) {
throw new Error(formatMessage("CP_NO_OPTS"));
}
@@ -16,6 +16,12 @@ export async function createPass(options: FactoryOptions): Promise {
readCertificatesFromOptions(options.certificates)
]);
+ if (additionalBuffers) {
+ const [ additionalL10n, additionalBundle ] = splitBundle(additionalBuffers);
+ Object.assign(bundle["l10nBundle"], additionalL10n);
+ Object.assign(bundle["bundle"], additionalBundle);
+ }
+
return new Pass({
model: bundle,
certificates,
@@ -26,3 +32,18 @@ export async function createPass(options: FactoryOptions): Promise {
throw new Error(formatMessage("CP_INIT_ERROR"));
}
}
+
+/**
+ * Applies a partition to split one bundle
+ * to two
+ * @param origin
+ */
+
+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] }]
+ , [{},{}]);
+}