@@ -2,6 +2,17 @@ const { promises: fs } = require('fs');
2
2
const axios = require ( 'axios' ) ;
3
3
const { items : videos } = require ( './videos.json' ) ;
4
4
5
+ const ignoreFiles = {
6
+ 'README.md' : true ,
7
+ '.vscode' : true ,
8
+ 'node_modules' : true ,
9
+ '.eslintrc.js' : true ,
10
+ 'package.json' : true ,
11
+ 'package-lock.json' : true ,
12
+ 'example.js' : true ,
13
+ 'scratch.js' : true ,
14
+ } ;
15
+
5
16
( async ( ) => {
6
17
const katas = [ ] ;
7
18
let tableOfContents = `# Code Katas
@@ -13,9 +24,11 @@ Search / Filter solutions [here](https://code-katas.now.sh/)
13
24
` ;
14
25
const files = await fs . readdir ( '../' , 'utf8' ) ;
15
26
files . reverse ( ) ;
16
- for ( const directory of files ) {
27
+ let episodeCount = 0 ;
28
+ for ( let i = 0 ; i < files . length ; i ++ ) {
29
+ const directory = files [ i ] ;
17
30
if ( directory . startsWith ( 'episode' ) && directory !== 'episode_000' ) {
18
- const episodeNum = + directory . replace ( 'episode_' , '' ) ;
31
+ const episodeNum = directory . replace ( 'episode_' , '' ) ;
19
32
const solutions = await fs . readdir ( `../${ directory } ` , 'utf8' ) ;
20
33
21
34
const {
@@ -24,7 +37,8 @@ Search / Filter solutions [here](https://code-katas.now.sh/)
24
37
videoId
25
38
}
26
39
}
27
- } = videos [ episodeNum - 1 ] ;
40
+ } = videos [ episodeCount ] ;
41
+ episodeCount ++ ;
28
42
29
43
const video = `https://www.youtube.com/watch?v=${ videoId } ` ;
30
44
@@ -36,7 +50,7 @@ Search / Filter solutions [here](https://code-katas.now.sh/)
36
50
`
37
51
const episodeKatas = [ ] ;
38
52
for ( const name of solutions ) {
39
- if ( name . endsWith ( '.js' ) ) {
53
+ if ( ! ignoreFiles [ name ] ) {
40
54
const slug = name . replace ( '.js' , '' ) ;
41
55
const githubUrl = `https://github.com/CodingGarden/code-katas/blob/master/${ directory } /${ name } ` ;
42
56
try {
@@ -56,7 +70,7 @@ Search / Filter solutions [here](https://code-katas.now.sh/)
56
70
}
57
71
} ) ;
58
72
} catch ( error ) {
59
- console . log ( slug , 'not found...' )
73
+ console . log ( slug , 'not found...' ) ;
60
74
}
61
75
}
62
76
}
0 commit comments