Skip to content

Instantly share code, notes, and snippets.

@rspieker
Last active January 20, 2016 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rspieker/fddfc3f5a92e04bc82b2 to your computer and use it in GitHub Desktop.
Save rspieker/fddfc3f5a92e04bc82b2 to your computer and use it in GitHub Desktop.
Convert glue < 3 manifest to 3+ syntax
// compensate for old Glue configuration syntax
function convertGluePluginManifest(manifest) {
if ('plugins' in manifest) {
if (!manifest.connections || manifest.connections.length !== 1) {
throw new Error('it is probably a Bad Idea™ to bluntly convert the old Glue "plugins" to reside on all connections');
}
if (!('registrations' in manifest)) {
manifest.registrations = [];
}
Object.keys(manifest.plugins)
.forEach(register => {
let options = manifest.plugins[register];
manifest.registrations.push({plugin: options ? {
register: register,
options: options
} : register});
});
delete manifest.plugins;
}
return manifest;
}
// compensate for old Glue configuration syntax
function convertGluePluginManifest(manifest) {
if ('plugins' in manifest) {
if (!manifest.connections || manifest.connections.length !== 1) {
throw new Error('it is probably a Bad Idea™ to bluntly convert the old Glue "plugins" to reside on all connections');
}
if (!('registrations' in manifest)) {
manifest.registrations = [];
}
Object.keys(manifest.plugins)
.forEach(function(register) {
var options = manifest.plugins[register];
manifest.registrations.push({plugin: options ? {
register: register,
options: options
} : register});
});
delete manifest.plugins;
}
return manifest;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment