Skip to content

Instantly share code, notes, and snippets.

@regmicmahesh
Created April 20, 2021 17:15
Show Gist options
  • Save regmicmahesh/189f46f528ab39b6517f6e8f3240ba32 to your computer and use it in GitHub Desktop.
Save regmicmahesh/189f46f528ab39b6517f6e8f3240ba32 to your computer and use it in GitHub Desktop.
ts setup
#!/bin/bash
echo "npm/yarn?"
read pm
echo "Selected $pm"
read -r -d '' tsconfig << EOM
{
"compilerOptions": {
"module": "commonjs",
"outDir": "./build/",
"rootDir": "./src/",
"strict": true,
"baseUrl": "./",
"paths": {
"*" : ["node_modules"]
},
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}
EOM
read -r -d '' package << EOM
{
"scripts": {
"dev": "concurrently --kill-others \"tsc -w\" \"nodemon dist/app.js\""
}
}
EOM
case $pm in
npm)
echo -e "$package" >> package.json
echo -e "$tsconfig" > tsconfig.json
sudo npm i -g typescript concurrently nodemon
echo "$ts_config" >> tsconfig.json
mkdir src dist
touch src/app.ts dist/app.js
echo "npm run dev to get started."
;;
yarn)
echo -e "$package" >> package.json
echo -e "$tsconfig" > tsconfig.json
yarn global add typescript concurrently nodemon
echo "ts_config" >> tsconfig.json
mkdir src
mkdir dist
touch src/app.ts
echo "yarn dev to get started."
;;
*)
echo -n "Unknown"
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment