Skip to content

Instantly share code, notes, and snippets.

@MouseZero
Created January 10, 2019 19:08
Show Gist options
  • Save MouseZero/219cd0665eb1f4806b68984dec1367e9 to your computer and use it in GitHub Desktop.
Save MouseZero/219cd0665eb1f4806b68984dec1367e9 to your computer and use it in GitHub Desktop.
#!/bin/bash
projectName=$1
folderPath="/code/tmp/${projectName}"
if [[ ! $projectName ]]; then
echo "You need to specify a project name"
exit 1
fi
if [ -d "${folderPath}" ]; then
echo "There is already a tmp project with that name"
exit 1
fi
mkdir "${folderPath}"
echo 'console.log("test")' >> "${folderPath}/index.js"
cat > "${folderPath}/index.html" <<EOL
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="index.js"></script>
<title>Test</title>
</head>
<body>
</body>
</html>
EOL
cd "${folderPath}" && npm init -y && git init
echo "folderPath"
echo "${folderPath}"
echo "browser path:"
echo "${folderPath}/index.html"
code "${folderPath}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment