Skip to content

Instantly share code, notes, and snippets.

@rossipedia
Created September 24, 2016 23:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rossipedia/e7f73a7a3712010142da2b0b66901f09 to your computer and use it in GitHub Desktop.
Save rossipedia/e7f73a7a3712010142da2b0b66901f09 to your computer and use it in GitHub Desktop.
// 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