Created
July 6, 2014 09:24
-
-
Save cahna/95d4a7cba13ee1fa898f to your computer and use it in GitHub Desktop.
Moonscript - read environment variable shorthand
This file contains hidden or 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
-- Package that helper into the worlds shortest module. | |
-- Usage: import HOME, SHELL, EDITOR from require 'ENV' | |
setmetatable {}, __index: (k) => os.getenv k |
This file contains hidden or 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
-- Nifty shorthand for creating local variables from environment variables in moonscript using metatables | |
import HOME, SHELL, EDITOR from setmetatable {}, __index: (k) => os.getenv k | |
-- are both equivalent to: | |
HOME = os.getenv "HOME" | |
SHELL = os.getenv "SHELL" | |
EDITOR = os.getenv "EDITOR" |
This file contains hidden or 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
import HOME, SHELL, EDITOR from require 'ENV' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment