Skip to content

Instantly share code, notes, and snippets.

@hhff
Last active February 10, 2019 21:13
Show Gist options
  • Save hhff/5811a06a253ef87b9707ad01b0f2f2f1 to your computer and use it in GitHub Desktop.
Save hhff/5811a06a253ef87b9707ad01b0f2f2f1 to your computer and use it in GitHub Desktop.
webhook2contentful: generator.js modifications
module.exports.generator = function (config, options, logger, fileParser) {
/* ...Snip */
/* Paste this right at the end of the file */
let oldGetBucket;
[getBucket, oldGetBucket] =
require(`${__dirname}/contentful/decorators/getBucket`)(getBucket);
let oldGetDnsChild;
[getDnsChild, oldGetDnsChild] =
require(`${__dirname}/contentful/decorators/getDnsChild`)(getDnsChild);
this.migrateToContentful = function(done, cb) {
oldGetBucket().once('value', function(data) {
data = data.val() || {};
let typeInfo = data['contentType'] || {};
let settings = data['settings'] || {};
data = data['data'] || {};
require(`${__dirname}/contentful`)(data, typeInfo, settings, done, cb);
});
}
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment