-
Notifications
You must be signed in to change notification settings - Fork 413
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
base: master
Are you sure you want to change the base?
add task solution #166
Conversation
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.
src/modules/copyFile.js
Outdated
const data = fs.readFileSync(sourcePath, 'utf-8'); | ||
|
||
fs.writeFileSync(destPath, data, 'utf-8'); |
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.
Not all files are utf-8
, don't pass this param and work with raw buffers
const data = fs.readFileSync(sourcePath, 'utf-8'); | |
fs.writeFileSync(destPath, data, 'utf-8'); | |
const data = fs.readFileSync(sourcePath); | |
fs.writeFileSync(destPath, data); |
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.
Try copying an executable file, it will not work afterwards
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.
src/modules/copyFile.js
Outdated
const data = fs.readFileSync(sourcePath, 'utf-8'); | ||
|
||
fs.writeFileSync(destPath, data, 'utf-8'); |
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.
Try copying an executable file, it will not work afterwards
src/modules/copyFile.js
Outdated
|
||
fs.writeFileSync(destPath, data, 'utf-8'); | ||
} catch (error) { | ||
throw new Error('Something went wrong: ', error); |
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 throw new Error? At least save the message. Also the second param is wrong
throw new Error('Something went wrong: ', error); | |
throw new Error('Something went wrong: ' + error.message); |
src/app.js
Outdated
const sourcePath = path.join(__dirname, source); | ||
const destPath = path.join(__dirname, dest); |
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.
Don't join __dirname, your program will not work outside of src
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.
👍
No description provided.