Created
September 24, 2016 23:23
-
-
Save rossipedia/e7f73a7a3712010142da2b0b66901f09 to your computer and use it in GitHub Desktop.
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
// See https://github.com/facebook/jscodeshift for instructions on how to use codemods | |
module.exports = function ({path, source}, {jscodeshift: shift}, opts) { | |
return shift(source) | |
.find(shift.MemberExpression, { | |
object: { | |
object: { | |
type: 'Identifier', | |
name: 'process' | |
}, | |
property: { | |
type: 'Identifier', | |
name: 'env' | |
} | |
} | |
}) | |
.replaceWith(p => { | |
const name = p.value.property.name; | |
const value = process.env[name]; | |
return shift.literal(value); | |
}) | |
.toSource(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment