-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
# script for creating a new problem in a directory with the name of the problem | ||
# and the files index.js, index.test.js, and README.md | ||
echo '📁 Which directory do you want to create the solution? ' | ||
read directory | ||
|
||
# validate if the directory exists, if not, create it | ||
if [ ! -d "$directory" ]; then | ||
echo '📁 The directory does not exist, do you want to create it? (y/n)' | ||
read createDirectory | ||
if [ "$createDirectory" = "y" ]; then | ||
mkdir "$directory" | ||
else | ||
echo '❌ You must create the directory' | ||
exit 1 | ||
fi | ||
fi | ||
|
||
cd "$directory" | ||
|
||
echo '🎯 What is the name of the problem? ' | ||
read problem | ||
|
||
|
||
directoryName=$(echo "$problem" | tr ' ' '-') | ||
mkdir "$directoryName" | ||
|
||
cd "$directoryName" | ||
|
||
touch "index.js" | ||
touch "README.md" | ||
|
||
problemNumber="${problem:0:2}" | ||
|
||
# primera letra en mayuscula | ||
problemName="${problem:3}" | ||
problemName="${problemName^}" | ||
|
||
echo "# Reto $problemNumber: $problemName" >> README.md | ||
echo "" >> README.md | ||
echo "## Enunciado" >> README.md | ||
echo "" >> README.md | ||
echo "## My solution" >> README.md | ||
echo "" >> README.md | ||
echo "## Explanation of my solution" >> README.md | ||
|
||
echo '✅ The problem has been created' |