File tree 3 files changed +28
-1
lines changed
3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 7
7
"scripts" : {
8
8
"task1" : " node ./src/task-1.js" ,
9
9
"task2" : " node ./src/task-2.js" ,
10
+ "task3" : " node ./src/task-3.js" ,
10
11
"test" : " echo \" Error: no test specified\" && exit 1"
11
12
},
12
13
"type" : " module" ,
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import c from "chalk";
3
3
import { appendFile , mkdir } from "node:fs/promises" ;
4
4
import readline from "node:readline/promises" ;
5
5
const fileName = "people.txt" ;
6
- const dirPath = new URL ( "./../database/task-1 " , import . meta. url ) . pathname ;
6
+ const dirPath = new URL ( "./../database/task-2 " , import . meta. url ) . pathname ;
7
7
8
8
console . log ( c . yellow . bold ( "LOGIN: " ) ) ;
9
9
const rl = readline . createInterface ( { input : process . stdin , output : process . stdout } ) ;
Original file line number Diff line number Diff line change
1
+ import { generateRandomUserDataString as newEntry } from "./generateRandomUserDataString.js" ;
2
+ import c from "chalk" ;
3
+ import { appendFile , mkdir } from "node:fs/promises" ;
4
+ import readline from "node:readline/promises" ;
5
+ const fileName = "people.txt" ;
6
+ const dirPath = new URL ( "./../database/task-2" , import . meta. url ) . pathname ;
7
+
8
+ console . log ( c . yellow . bold ( "LOGIN: " ) ) ;
9
+ const rl = readline . createInterface ( { input : process . stdin , output : process . stdout } ) ;
10
+ let login = await rl . question ( c . bgBlue . bold ( "username:" ) + " " ) ;
11
+ let password = await rl . question ( c . bgBlue . bold ( "password:" ) + " " ) ;
12
+
13
+ if ( login . trim ( ) !== "admin" || password . trim ( ) !== "1234" ) {
14
+ console . log ( c . red ( "Neteisingi prisijungimo duomenys" ) ) ;
15
+ rl . close ( ) ;
16
+ } else {
17
+ await mkdir ( dirPath , { recursive : true } ) ;
18
+ try {
19
+ await appendFile ( `${ dirPath } /${ fileName } ` , newEntry ( ) ) ; ///kelias ne nuo sito failo, bet nuo project rooto??...
20
+ console . log ( c . green ( "Duomenys faile sėkmingai išsaugoti" ) ) ;
21
+ } catch ( err ) {
22
+ console . error ( err ) ;
23
+ } finally {
24
+ rl . close ( ) ;
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments