Skip to content

Commit

Permalink
🔨 Add script for create solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
marcode24 committed Jan 16, 2024
1 parent c5cf2dd commit 58e1fe6
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions create-solution.sh
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'

0 comments on commit 58e1fe6

Please sign in to comment.