-
Notifications
You must be signed in to change notification settings - Fork 427
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
Solution #358
base: master
Are you sure you want to change the base?
Solution #358
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Test | ||
|
||
on: | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [20.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm install | ||
- run: npm test |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
# Copy files | ||
|
||
**Read [the guideline](https://github.com/mate-academy/js_task-guideline/blob/master/README.md) before start** | ||
### Description | ||
|
||
Write an app in `app.js` file, that will copy a file from one specified location to another like | ||
Linux cp command: `cp file.txt file-copy.txt`. | ||
- Wrote an app that will copy a file from one specified location to another | ||
|
||
- It must do nothing in case the user is trying to copy to the same location. | ||
- The app must support only copying of files, and no additional options (flags). Plain copying of files. | ||
- Throw an error with the console.error() command | ||
### Stack | ||
|
||
## Node Version Requirement | ||
- Node | ||
|
||
### Note: Use Node.js version 20 or higher | ||
### Tools | ||
|
||
If you haven't installed a specific Node.js version, you can manage multiple Node.js versions on your machine using tools like [nvm (Node Version Manager)](https://github.com/nvm-sh/nvm) or [(Node.js version management)](https://nodejs.org/en/blog/release/v20.9.0). Ensure that the selected Node.js version aligns with the specified minimum version before proceeding with the project setup. | ||
- ESlint | ||
- Prettier | ||
- Jest |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,24 @@ | ||
/* eslint-disable no-console */ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
|
||
function copyFile() { | ||
const [src, dest] = process.argv.slice(2); | ||
|
||
if (!dest) { | ||
console.error('Please provide two arguments'); | ||
} | ||
|
||
try { | ||
if (src && dest && src !== dest) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The condition |
||
const fileData = fs.readFileSync(src, 'utf8'); | ||
|
||
fs.writeFileSync(dest, fileData); | ||
} | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
} | ||
|
||
copyFile(); |
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.
The code checks if the destination argument is missing and logs an error message, but it does not exit the function. Consider adding a return statement after logging the error to prevent further execution.