Created
April 29, 2016 22:05
-
-
Save danott/3e73a54688bc9a22512f7d76254bda3e to your computer and use it in GitHub Desktop.
A transform for use with jscodeshift
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
module.exports = function(fileInfo, api) { | |
var j = api.jscodeshift; | |
var out = j(fileInfo.source) | |
.find(j.Literal) | |
.forEach(function (path) { | |
// Only consider literals that start/end w/ double quotes | |
if (!/^'.*'$/.test(path.value.raw)) { | |
return; | |
} | |
j(path).replaceWith(j.literal(path.value.value)); | |
}) | |
.toSource({quote: 'double'}); | |
return out; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment