Created
June 5, 2012 13:10
-
-
Save jeremyrsellars/2874875 to your computer and use it in GitHub Desktop.
Beautiful Coffeescript try assignment for configuration
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
# 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', | |
} |
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
// 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