Skip to content

Instantly share code, notes, and snippets.

@danott
Created April 29, 2016 22:05
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 danott/3e73a54688bc9a22512f7d76254bda3e to your computer and use it in GitHub Desktop.
Save danott/3e73a54688bc9a22512f7d76254bda3e to your computer and use it in GitHub Desktop.
A transform for use with jscodeshift
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