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

developed #365

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"devDependencies": {
"@faker-js/faker": "^8.4.1",
"@mate-academy/eslint-config": "latest",
"@mate-academy/scripts": "^1.8.6",
"@mate-academy/scripts": "^1.9.12",
"eslint": "^8.57.0",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-node": "^11.1.0",
Expand Down
35 changes: 35 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
/* eslint-disable no-console */
'use strict';

const fs = require('fs');

const [source, destination] = process.argv.slice(2);

function copyFile(copyFrom, copyTo) {
try {
fs.existsSync(copyFrom);

Choose a reason for hiding this comment

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

The fs.existsSync(copyFrom); line is not being used correctly. This function returns a boolean indicating whether the file exists, but here it is not being checked. You should use it in a conditional statement to handle the case where the file does not exist.

} catch (error) {
console.error(error);
}

if (copyFrom === copyTo) {

Choose a reason for hiding this comment

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

The check if (copyFrom === copyTo) is correct in terms of logic, but it might be beneficial to log a message indicating that the source and destination are the same, and therefore no action will be taken.

return;
}

try {
const fileData = fs.readFileSync(copyFrom, 'utf8');

try {
fs.writeFileSync(copyTo, fileData, 'utf8');
} catch (error) {
console.error(error);
}
} catch (error) {
console.error(error);
}
}

copyFile(source, destination);

module.exports = {
copyFile,
};
Loading