Skip to content
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

new sol #148

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

new sol #148

wants to merge 5 commits into from

Conversation

yurii-krymskiy
Copy link

No description provided.

Copy link

@l4st1m0za l4st1m0za left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, but small change needed

src/app.js Outdated
throw new Error(err);
}

fs.rename(sourceAbsolutePath, finalDestination);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs.rename is an asynchronous operation and needs to be awaited, or else errors may go unhandled and operations may not complete in the expected order.

src/app.js Outdated

fs.rename(sourceAbsolutePath, finalDestination);
} catch (err) {
throw new Error(err);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are throwing a new error but not adding any additional context. Consider adding a custom error message to provide more information about what went wrong.

src/app.js Outdated
try {
await fs.access(destinationDirectory);
} catch (err) {
throw new Error(err);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are throwing a new error but not adding any additional context. Consider adding a custom error message to provide more information about what went wrong.

Copy link

@DarkMistyRoom DarkMistyRoom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix these errors
image

src/app.js Outdated
Comment on lines 24 to 28
try {
await fs.access(destinationDirectory);
} catch (err) {
throw new Error(`Destination directory does not exist: ${destinationDirectory}`);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider avoiding try catch nesting

src/app.js Outdated
const destinationAbsolutePath = path.resolve(destination);

try {
if (!(await fileExists(sourceAbsolutePath))) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like fileExists function is redundant

Suggested change
if (!(await fileExists(sourceAbsolutePath))) {
if (!(await fs.access(filePath))) {

src/app.js Outdated
const fs = require('fs').promises;
const path = require('path');

const fileExists = async (filePath) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is not used anywhere, so please remove it

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.

4 participants