Skip to content

Instantly share code, notes, and snippets.

@sandalsoft
Forked from aminmarashi/convert.sh
Created March 6, 2018 03:49
Show Gist options
  • Save sandalsoft/2c23f9abe1251dc9e837bea65c050e17 to your computer and use it in GitHub Desktop.
Save sandalsoft/2c23f9abe1251dc9e837bea65c050e17 to your computer and use it in GitHub Desktop.
Convert require to import using prettier
#!/bin/bash
find . -name '*.js' -exec gsed -i "s/const \(.*\) = require(\(.*\))\.\(.*\);/import { \3 as \1 } from \2;/g" '{}' ';'
prettier-eslint --write '**/*.js'
find . -name '*.js' -exec gsed -i "s/const \(.*\) = require(\(.*\));/import \1 from \2;/g" '{}' ';'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment