Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jeremyrsellars/2874875 to your computer and use it in GitHub Desktop.
Save jeremyrsellars/2874875 to your computer and use it in GitHub Desktop.
Beautiful Coffeescript try assignment for configuration
# prefer the config file, if it exists.
authOptions =
try
require './oauth.config.json'
catch e
{
'host': 'localhost',
'port': '80',
'token': '/account/token',
'principal': '/account/principal',
'client_id': 'MyApplication',
'client_secret': 'I love coffeescript',
}
// prefer the config file, if it exists.
authOptions = (function() {
try {
return require('./oauth.config.json');
} catch (e) {
return {
'host': 'localhost',
'port': '80',
'token': '/account/token',
'principal': '/account/principal',
'client_id': 'MyApplication',
'client_secret': 'I love coffeescript'
};
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment