* @param {?string} template path to an existing profile to use as a template. * @param {!Array } extensions paths to extensions to install in the new * profile. * @return {!Promise } a promise for the base64 encoded profile.
(template, extensions)
| 213 | * @return {!Promise<string>} a promise for the base64 encoded profile. |
| 214 | */ |
| 215 | async function buildProfile(template, extensions) { |
| 216 | let dir = template |
| 217 | |
| 218 | if (extensions.length) { |
| 219 | dir = await io.tmpDir() |
| 220 | if (template) { |
| 221 | await io.copyDir(/** @type {string} */ (template), dir, /(parent\.lock|lock|\.parentlock)/) |
| 222 | } |
| 223 | |
| 224 | const extensionsDir = path.join(dir, 'extensions') |
| 225 | await io.mkdir(extensionsDir) |
| 226 | |
| 227 | for (let i = 0; i < extensions.length; i++) { |
| 228 | await installExtension(extensions[i], extensionsDir) |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | let zip = new Zip() |
| 233 | return zip |
| 234 | .addDir(dir) |
| 235 | .then(() => zip.toBuffer()) |
| 236 | .then((buf) => buf.toString('base64')) |
| 237 | } |
| 238 | |
| 239 | /** |
| 240 | * Configuration options for the FirefoxDriver. |
no test coverage detected