You are here

function drush_prebid_build in Doubleclick for Publishers (DFP) 7.2

Builds the prebid.js file with all specified adapters.

Parameters

@adapters: Comma separated list of bid adapters that should be included in the bundled prebid.js file.

Return value

mixed The download location on success, FALSE otherwise.

1 string reference to 'drush_prebid_build'
prebid_drush_command in prebid/prebid.drush.inc
Implementation of hook_drush_command().

File

prebid/prebid.drush.inc, line 179
prebid.drush.inc

Code

function drush_prebid_build($adapters) {
  $library = drupal_get_path('module', 'prebid') . '/js/prebid';
  $package = $library . '/package.json';
  if (!file_exists($package)) {
    make_error('DOWNLOAD_ERROR', dt("Couldn't find the Prebid.js library. Run 'drush help prebid-clone'."));
    return FALSE;
  }
  if (drush_get_option('dev')) {
    $command = 'npx gulp build-bundle-dev --modules=%s';
  }
  else {
    $command = 'npx gulp build-bundle-prod --modules=%s';
  }
  drush_log(dt('Moving to the Prebid cloned directory'), LogLevel::OK);
  chdir($library);
  drush_log(dt('Running npm install...'), LogLevel::OK);
  drush_shell_exec('npm install');

  // Show the actual command.
  $actual_command = str_replace('%s', $adapters, $command);
  drush_log(dt('Running: @command', array(
    '@command' => $actual_command,
  )), LogLevel::OK);
  drush_shell_exec($command, $adapters);
}