Skip to content

Commit aab3f30

Browse files
authored
feat: add filename formatter and directory workflow (TheAlgorithms#76)
1 parent 69767aa commit aab3f30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+107
-27
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Directory/Filename Formatter workflow
2+
on: [push, pull_request]
3+
4+
jobs:
5+
main:
6+
name: (Directory) Formatter
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@main
10+
- name: Setup Git configuration
11+
run: |
12+
git config --global user.name 'autoprettier'
13+
git config --global user.email '[email protected]'
14+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
15+
- name: Filename Formatter
16+
run: |
17+
IFS=$'\n'
18+
for fname in `find . -type f -name '*.ts' -o -name '*.ts'`
19+
do
20+
echo "${fname}"
21+
new_fname=`echo ${fname} | tr ' ' '_'`
22+
echo " ${new_fname}"
23+
new_fname=`echo ${new_fname} | tr 'A-Z' 'a-z'`
24+
echo " ${new_fname}"
25+
new_fname=`echo ${new_fname} | tr '-' '_'`
26+
echo " ${new_fname}"
27+
if [ ${fname} != ${new_fname} ]
28+
then
29+
echo " ${fname} --> ${new_fname}"
30+
git "mv" "${fname}" ${new_fname}
31+
fi
32+
done
33+
git commit -am "Formatting filenames ${GITHUB_SHA::8}" || true
34+
- name: Update DIRECTORY.md
35+
run: |
36+
wget https://raw.githubusercontent.com/TheAlgorithms/scripts/main/build_directory_md.py
37+
python3 build_directory_md.py TypeScript . .ts jest.config.ts,sorts/test,search/test,maths/test,dynamic_programming/test,data_structures/test,ciphers/test > DIRECTORY.md
38+
39+
git diff
40+
git commit -m "Update DIRECTORY.md" DIRECTORY.md || true
41+
git push --force origin HEAD:$GITHUB_REF || true

DIRECTORY.md

Lines changed: 39 additions & 0 deletions

Ciphers/test/XORCipher.test.ts renamed to ciphers/test/xor_cipher.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { XORCipher } from '../XORCipher';
1+
import { XORCipher } from '../xor_cipher';
22

33
describe('Testing XORCipher function', () => {
44
it('passing a string & number as an argument', () => {
File renamed without changes.
File renamed without changes.

Data-Structures/test/Stack.test.ts renamed to data_structures/test/stack.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Stack } from '../Stack';
1+
import { Stack } from '../stack';
22

33
describe('Testing Stack data structure', () => {
44
it('push should add a new element to the stack', () => {
File renamed without changes.

dynamic_programing/test/Knapsack.test.ts renamed to dynamic_programming/test/knapsack.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { knapsack } from "../Knapsack";
1+
import { knapsack } from "../knapsack";
22

33
const cases: [number, number[], number[], number][] = [
44
[15, [6, 5, 6, 6, 3, 7], [5, 6, 4, 6, 5, 2], 17],
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)