diff options
author | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2019-11-30 07:18:38 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-30 07:18:38 -0500 |
commit | 119c621d5298f832ac469ba482624c1d1cbb43c3 (patch) | |
tree | 82966d4febd04c008f7e8592d067b053cbd67f68 | |
parent | dcb1b0fbbeb24fd253c8bf8713b793c6a81f7e24 (diff) | |
parent | e4569fab098cce9be5234fac6148f514959cae0e (diff) | |
download | kronikarz-119c621d5298f832ac469ba482624c1d1cbb43c3.tar.gz kronikarz-119c621d5298f832ac469ba482624c1d1cbb43c3.zip |
Merge pull request #2 from pniedzwiedzinski/develop v1.0.1
Add error handling
-rw-r--r-- | lib/getPosts.ts | 31 | ||||
-rw-r--r-- | package.json | 2 |
2 files changed, 16 insertions, 17 deletions
diff --git a/lib/getPosts.ts b/lib/getPosts.ts index 1821f12..38e419c 100644 --- a/lib/getPosts.ts +++ b/lib/getPosts.ts @@ -4,27 +4,26 @@ import { readDir } from "./utils"; function getPosts(path: string): Array<Post> { let routesArray: Post[] = []; - try { - const years = readDir(`${path}`); - years.forEach((year: string) => { - const months = readDir(`${path}/${year}`); - months.forEach((month: string) => { - const days = readDir(`${path}/${year}/${month}`); - days.forEach((day: string) => { - const files = readDir(`${path}/${year}/${month}/${day}`); - files.forEach((file: string) => { - const fsRoute = `${path}/${year}/${month}/${day}/${file}`; - + const years = readDir(`${path}`); + years.forEach((year: string) => { + const months = readDir(`${path}/${year}`); + months.forEach((month: string) => { + const days = readDir(`${path}/${year}/${month}`); + days.forEach((day: string) => { + const files = readDir(`${path}/${year}/${month}/${day}`); + files.forEach((file: string) => { + const fsRoute = `${path}/${year}/${month}/${day}/${file}`; + try { const post = parsePost(fsRoute); - routesArray.push(post); - }); + } catch (err) { + console.log(err); + } }); }); }); - } finally { - return routesArray; - } + }); + return routesArray; } function createRoutesArray() { diff --git a/package.json b/package.json index 2d33b18..2a63af7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kronikarz", - "version": "1.0.0", + "version": "1.0.1", "description": "System elektronicznej kroniki", "main": "dist/index.js", "types": "dist/index.d.ts", |