Created
May 26, 2016 15:54
-
-
Save Bargs/5176a16599e2e0b75dca8bf109183d62 to your computer and use it in GitHub Desktop.
Remove 'ui' webpack alias from imports
This file contains 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 _ from 'lodash'; | |
import path from 'path'; | |
export default function transformer(file, api) { | |
const j = api.jscodeshift; | |
const {expression, statement, statements} = j.template; | |
let relativeToPublic = path.relative(path.dirname(file.path), '/Users/matt/Code/kibana/src/ui/public'); | |
if (relativeToPublic === '') { | |
relativeToPublic = '.'; | |
} | |
// console.log(file.path); | |
// console.log(relativeToPublic); | |
return j(file.source) | |
.find(j.ImportDeclaration) | |
.forEach((path) => { | |
if (path.node.source.value.startsWith('ui')) { | |
path.node.source.value = path.node.source.value.replace('ui', relativeToPublic); | |
} | |
}) | |
.toSource({quote: 'single'}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment