Skip to content

Conversation

@benjaminbojko
Copy link

Allows for a custom filter function to run string operations on the DB dump before importing it to each environment.

For example, this allows for custom fixes regarding MySQL warnings as discussed in #6, #37 and #34 by adding the following filter:

local: {
  'title': 'local',
  //...
  'filter': function(mysql_dump) {
    return mysql_dump.replace(/^Warning.*\n?/gm, ''); // filter MySQL warnings
  }
}

I've also used it to switch between wordpress themes when pushing/pulling from/to local:

local: {
  'title': 'local',
  //...
  'filter': function(mysql_dump) {
    return mysql_dump
      .replace(/^Warning.*\n?/gm, '') // filter MySQL warnings
      .replace(/'(current_theme)','My Production Theme'/g, '\'$1\',\'My Development Theme\'')
      .replace(/'(stylesheet|template)','my-production-theme-folder'/g, '\'$1\',\'my-dev-theme-folder\'');
  }
}
//...
staging: {
  'title': 'staging',
  //...
  'filter': function(mysql_dump) {
    return mysql_dump
      .replace(/^Warning.*\n?/gm, '') // filter MySQL warnings
      .replace(/'(current_theme)','My Development Theme'/g, '\'$1\',\'My Production Theme\'')
      .replace(/'(stylesheet|template)','my-dev-theme-folder'/g, '\'$1\',\'my-production-theme-folder\'');
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants