Skip to content

Instantly share code, notes, and snippets.

@AlbinoDrought
Created August 16, 2017 21:49
Show Gist options
  • Save AlbinoDrought/1ca5b85b292dcb53872e7635179f8b50 to your computer and use it in GitHub Desktop.
Save AlbinoDrought/1ca5b85b292dcb53872e7635179f8b50 to your computer and use it in GitHub Desktop.
#!/bin/sh
# create-index.sh
# Creates an ES6-compatible index.js file for all files in a folder.
#
# Usage:
# ./create-index.sh src/
# Recursive Usage:
# ls -R src/ | grep : | sed 's/://' | xargs -I@ ./create-index.sh @
#
# By default, includes all file extensions (.js, .vue)
# To configure, hack it yourself ;)
ls -p --sort=extension $1 | grep -v / | grep -v index | sed 's/\.[^.]*$//' | xargs -I@ echo "export { default as @ } from './@';" > $1/index.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment