Skip to content

Instantly share code, notes, and snippets.

@koji
Last active May 8, 2021 20:19
Show Gist options
  • Save koji/d06cb38ce10e6a5378dffe1199928d3b to your computer and use it in GitHub Desktop.
Save koji/d06cb38ce10e6a5378dffe1199928d3b to your computer and use it in GitHub Desktop.
Temporary script for
#!/bin/bash
# create tsconfig.json
echo "Create tsconfig.json"
touch tsconfig.json

# install packages for typescript
echo "install packages"
YARNCOMMAND='yarn add --dev typescript @types/react @types/node'
if $YARNCOMMAND ; then
    echo "installed package by yarn"
    yarn dev
else
    npm install --save-dev typescript @types/react @types/node
    echo "installed package by npm"
    npm run dev
fi

# change ext from .js file to .ts/.tsx
echo "rename files"
find pages -name "_app.js" -or -name "index.js" | sed 'p;s/.js$/.tsx/' | xargs -n2 mv & \\n  find pages/api -name "*.js" | sed 'p;s/.js$/.ts/' | xargs -n2 mv
echo "done ✌️"

#!/bin/bash
echo "Create tsconfig.json"
touch tsconfig.json
echo "install packages"
YARNCOMMAND='yarn add --dev typescript @types/react @types/node'
if $YARNCOMMAND ; then
echo "installed package by yarn"
else
npm install --save-dev typescript @types/react @types/node
echo "installed package by npm"
fi
# WIP
echo "rename files"
find pages -name "_app.js" -or -name "index.js" | sed 'p;s/.js$/.tsx/' | xargs -n2 mv & \\n find pages/api -name "*.js" | sed 'p;s/.js$/.ts/' | xargs -n2 mv
echo "done ✌️"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment