-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: Refactor algorithm creation script for user-friendly sim…
…plicity
- Loading branch information
1 parent
1c52208
commit 28d115f
Showing
2 changed files
with
15 additions
and
16 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
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 |
---|---|---|
@@ -1,27 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# Check if the correct number of arguments is provided | ||
if [ "$#" -ne 3 ]; then | ||
echo "Usage: $0 <category> <algorithm.js> <algorithm.test.js>" | ||
if [ "$#" -ne 2 ]; then | ||
echo "Usage: $0 <category> <algorithm>" | ||
exit 1 | ||
fi | ||
|
||
category="$1" | ||
algorithm_js="$2" | ||
algorithm_test_js="$3" | ||
algorithm="$2" | ||
category_path="${category}/tests" | ||
|
||
# Create the category directory and the tests directory if they don't exist | ||
mkdir -p "$category_path" | ||
|
||
# Create the algorithm file | ||
algorithm_file_path="${category}/${algorithm_js}" | ||
touch "$algorithm_file_path" | ||
echo "// Implement your algorithm here" > "$algorithm_file_path" | ||
# Create the algorithm.js file | ||
algorithm_js="${category}/${algorithm}.js" | ||
touch "$algorithm_js" | ||
echo "// Implement your algorithm here" > "$algorithm_js" | ||
|
||
# Create the test file | ||
test_file_path="${category_path}/${algorithm_test_js}" | ||
touch "$test_file_path" | ||
echo "// Implement tests for your algorithm here" > "$test_file_path" | ||
# Create the algorithm.test.js file | ||
algorithm_test_js="${category_path}/${algorithm}.test.js" | ||
touch "$algorithm_test_js" | ||
echo "// Implement tests for your algorithm here" > "$algorithm_test_js" | ||
|
||
echo "Created $algorithm_file_path and $test_file_path" | ||
echo "Created $algorithm_js and $algorithm_test_js" |