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

add task solution #166

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

add task solution #166

wants to merge 2 commits into from

Conversation

ollavka
Copy link

@ollavka ollavka commented Jul 31, 2023

No description provided.

Copy link
Contributor

@And678 And678 left a comment

Choose a reason for hiding this comment

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

Doesn't work:
image

Comment on lines 11 to 13
const data = fs.readFileSync(sourcePath, 'utf-8');

fs.writeFileSync(destPath, data, 'utf-8');
Copy link
Contributor

Choose a reason for hiding this comment

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

Not all files are utf-8, don't pass this param and work with raw buffers

Suggested change
const data = fs.readFileSync(sourcePath, 'utf-8');
fs.writeFileSync(destPath, data, 'utf-8');
const data = fs.readFileSync(sourcePath);
fs.writeFileSync(destPath, data);

Copy link
Contributor

Choose a reason for hiding this comment

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

Try copying an executable file, it will not work afterwards

Copy link
Contributor

@And678 And678 left a comment

Choose a reason for hiding this comment

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

Doesn't work:
image

Comment on lines 11 to 13
const data = fs.readFileSync(sourcePath, 'utf-8');

fs.writeFileSync(destPath, data, 'utf-8');
Copy link
Contributor

Choose a reason for hiding this comment

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

Try copying an executable file, it will not work afterwards


fs.writeFileSync(destPath, data, 'utf-8');
} catch (error) {
throw new Error('Something went wrong: ', error);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why throw new Error? At least save the message. Also the second param is wrong

Suggested change
throw new Error('Something went wrong: ', error);
throw new Error('Something went wrong: ' + error.message);

src/app.js Outdated
Comment on lines 15 to 16
const sourcePath = path.join(__dirname, source);
const destPath = path.join(__dirname, dest);
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't join __dirname, your program will not work outside of src

@ollavka ollavka requested a review from And678 August 7, 2023 16:34
Copy link
Contributor

@And678 And678 left a comment

Choose a reason for hiding this comment

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

👍

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.

2 participants