Last active
January 20, 2016 12:11
-
-
Save rspieker/fddfc3f5a92e04bc82b2 to your computer and use it in GitHub Desktop.
Convert glue < 3 manifest to 3+ syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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