File tree 2 files changed +13
-5
lines changed
2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 1
- import { getImportedNotesErrors , getImportedNotesStatus , importNotes } from './src/notes_importer.js'
1
+ import { getImportedWithErrorsNotes , getImportedNotesStatus , importNotes } from './src/notes_importer.js'
2
2
import { cleanDb } from './src/db.js'
3
3
4
4
await main ( )
@@ -14,6 +14,9 @@ async function main() {
14
14
case '--import' :
15
15
await importNotes ( args [ 1 ] )
16
16
return
17
+ case '--import-with-errors' :
18
+ await importNotes ( args [ 1 ] , true )
19
+ return
17
20
case '--status' :
18
21
await printStatus ( args [ 1 ] )
19
22
return
@@ -43,7 +46,7 @@ async function printStatus(notesDir) {
43
46
}
44
47
45
48
async function showErrors ( ) {
46
- ( await getImportedNotesErrors ( ) ) . forEach ( ( noteStatus , index ) => {
49
+ ( await getImportedWithErrorsNotes ( ) ) . forEach ( ( noteStatus , index ) => {
47
50
console . log ( `${ index + 1 } . "${ noteStatus . filePath } ":` )
48
51
console . log ( `${ noteStatus . error ?. message || noteStatus . error } \n` )
49
52
} )
Original file line number Diff line number Diff line change @@ -6,13 +6,18 @@ import { addImportStatus, loadImportStatuses } from './db.js'
6
6
7
7
const importedNotes = { }
8
8
9
- export async function importNotes ( notesDir ) {
9
+ export async function importNotes ( notesDir , onlyWithErrors = false ) {
10
10
const importedNoteList = await loadImportStatuses ( )
11
11
importedNoteList . forEach ( noteInfo => importedNotes [ noteInfo . filePath ] = noteInfo )
12
12
console . info ( `\nLoaded already imported ${ importedNoteList . length } notes` )
13
13
14
14
// noinspection JSValidateTypes
15
- const { files } = getNotesFiles ( notesDir )
15
+ let files
16
+ if ( onlyWithErrors ) {
17
+ files = importedNoteList . filter ( it => it . error ) . map ( it => it . filePath )
18
+ } else {
19
+ files = getNotesFiles ( notesDir ) . files
20
+ }
16
21
17
22
let fileIndex = 0
18
23
for ( const relFilePath of files ) {
@@ -111,6 +116,6 @@ export async function getImportedNotesStatus(notesDir) {
111
116
}
112
117
}
113
118
114
- export async function getImportedNotesErrors ( ) {
119
+ export async function getImportedWithErrorsNotes ( ) {
115
120
return ( await loadImportStatuses ( ) ) . filter ( it => it . error )
116
121
}
You can’t perform that action at this time.
0 commit comments