Skip to content

Instantly share code, notes, and snippets.

@aminmarashi
Created April 19, 2017 03:02
Show Gist options
  • Save aminmarashi/0e4cbed807b2d016733da2c644001c18 to your computer and use it in GitHub Desktop.
Save aminmarashi/0e4cbed807b2d016733da2c644001c18 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