-
Notifications
You must be signed in to change notification settings - Fork 0
Nodejs basics #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| @@ -1,5 +1,22 @@ | |||
| import fs from "fs"; | |||
| import path from "path"; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import path, { dirname } from "path";
You have two imports from one module
| throw new Error("FS operation failed"); | ||
| } | ||
|
|
||
| fs.writeFileSync(filePath, MESSAGE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В задании рекомендовано использовать асинхронные методы. Сейчас это не важно, но в данное задание - подготовка к следующим и там синхронные уже не прокатят.
| // Write your code here | ||
| const filePath = path.join(__dirname, DIR, FILE_NAME); | ||
|
|
||
| if (fs.existsSync(filePath)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мне кажется, здесь Вы делаете лишнюю работу, но она недостаточна...
При работе с файловой системой могут возникнуть разнообразные эксепшины, которые Вы не отлавливаете.
Вам нужно было writeFile обернуть в блок try ... catch, в метод передать флаг wx (он бы выбрасывал исключение , если файл уже существует), это исключение отлавливалось бы в кетче (наравне с любыми другими ошибками).
| let destPath = path.join(dest, entry.name); | ||
|
|
||
| entry.isDirectory() | ||
| ? copyDirectory(srcPath, destPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is copyDirectory??? Where is it?
| const __filename = fileURLToPath(import.meta.url); | ||
| const __dirname = dirname(__filename); | ||
|
|
||
| const read = async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another version of list.js?
Something is wrong here.
| @@ -1,5 +1,14 @@ | |||
| const ENV_NAME="RSS_"; | |||
| process.env.RSS_name1 = 'value1'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this is here???
This side effect gives the wrong result of function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should rename this file.
| const compress = async () => { | ||
| // Write your code here | ||
| const inputFilePath = path.join(__dirname,DIR,FILE_NAME); | ||
| const outputFilePath = path.join(__dirname, ARCHIVE_NAME); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you move result file to another folder?
| const decompress = async () => { | ||
| // Write your code here | ||
| const inputFilePath = path.join(__dirname,ARCHIVE_NAME); | ||
| const outputFilePath = path.join(__dirname, DIR, FILE_NAME); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you move result file to another folder?
Link to the task: https://github.com/AlreadyBored/nodejs-assignments/blob/main/assignments/nodejs-basics/assignment.md
Deadline: 2024-01-30 01:00
Self-check: I realized almost all of the subtasks, the difficult ones for me were the treads
For check simplification you have npm-scripts in package.json.
NB! Some scripts have predefined data (e.g. environment variables, CLI arguments). Feel free to change it during the check if necessary.
Basic Scope (166/206)
File system (src/fs)
+6 create.js implemented properly
+10 copy.js implemented properly
+10 rename.js implemented properly
+6 delete.js implemented properly
+6 list.js implemented properly
+6 read.js implemented properly
Command line interface(src/cli)
+6 env.js implemented properly
+6 args.js implemented properly
Modules(src/modules)
+20 cjsToEsm.cjs refactored properly
Hash (src/hash)
+10 calcHash.js implemented properly
Streams (src/streams)
+10 read.js implemented properly
+10 write.js implemented properly
+10 transform.js implemented properly
Zlib (src/zip)
+10 compress.js implemented properly
+10 decompress.js implemented properly
Advanced Scope
Worker Threads (src/wt)
+10 worker.js implemented properly
+30 main.js implemented properly
Child Processes (src/cp)
+10 spawns child process
+10 child process stdin receives input from master process stdin
+10 child process stdout sends data to master process stdout