Skip to content

Conversation

@kirillGovor
Copy link
Owner

@kirillGovor kirillGovor commented Jan 29, 2024

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

@@ -1,5 +1,22 @@
import fs from "fs";
import path from "path";
Copy link

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);
Copy link

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)) {
Copy link

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)
Copy link

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 () => {
Copy link

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';
Copy link

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.

Copy link

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);
Copy link

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);
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants