function flatApplicationAsync (opts) {
  var args = [
    '--component', opts.app, opts.install,
    '--sign', opts.identity.name,
    opts.pkg
  ]
  if (opts.keychain) {
    args.unshift('--keychain', opts.keychain)
  }
  if (opts.scripts) {
    args.unshift('--scripts', opts.scripts)
  }

  debuglog('Flattening... ' + opts.app)
  return execFileAsync('productbuild', args)
    .thenReturn(undefined)
}
This function returns a promise flattening the application.
@function
@param {Object} opts - Options.
@returns {Promise} Promise.