From 8bf43538d355224194cca663d3742c780ebe7f0d Mon Sep 17 00:00:00 2001 From: Arthur Tolkachov Date: Thu, 1 Aug 2024 14:26:03 +0300 Subject: [PATCH 1/2] [Feature] added copy files app --- .eslintrc.js | 14 +++++++++++--- package.json | 2 +- src/app.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index f44c7a1..ad66b17 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,10 +1,18 @@ module.exports = { extends: '@mate-academy/eslint-config', env: { - jest: true + jest: true, }, rules: { - 'no-proto': 0 + 'no-proto': 0, + 'no-unused-vars': [ + 'error', + { + varsIgnorePattern: '^_', + caughtErrorsIgnorePattern: '^_', + }, + ], + 'no-console': ['error', { allow: ['error'] }], }, - plugins: ['jest'] + plugins: ['jest'], }; diff --git a/package.json b/package.json index 783242d..567e80a 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "devDependencies": { "@faker-js/faker": "^8.3.1", "@mate-academy/eslint-config": "latest", - "@mate-academy/scripts": "^1.7.3", + "@mate-academy/scripts": "^1.8.6", "eslint": "^7.32.0", "eslint-plugin-jest": "^22.4.1", "eslint-plugin-node": "^8.0.1", diff --git a/src/app.js b/src/app.js index ad9a93a..af8226c 100644 --- a/src/app.js +++ b/src/app.js @@ -1 +1,31 @@ 'use strict'; + +const fs = require('fs'); + +const copyFile = async () => { + const [_bin, _app, srcFile, destinationFile] = process.argv; + + if (!srcFile || !destinationFile) { + console.error('No such file of destination'); + + return; + } + + if (srcFile === destinationFile) { + return; + } + + fs.readFile(srcFile, (readingErr, fileCopy) => { + if (readingErr) { + console.error(readingErr); + } else { + fs.writeFile(destinationFile, fileCopy, (writingErr) => { + if (writingErr) { + console.error(writingErr); + } + }); + } + }); +}; + +copyFile(); From af09eeceb33f7d93e416b22b34695eeaa2df3f3d Mon Sep 17 00:00:00 2001 From: Arthur Tolkachov Date: Thu, 1 Aug 2024 14:38:45 +0300 Subject: [PATCH 2/2] [Fix] ignore errors --- .eslintrc.js | 8 -------- src/app.js | 2 ++ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index ad66b17..3ff8c23 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -5,14 +5,6 @@ module.exports = { }, rules: { 'no-proto': 0, - 'no-unused-vars': [ - 'error', - { - varsIgnorePattern: '^_', - caughtErrorsIgnorePattern: '^_', - }, - ], - 'no-console': ['error', { allow: ['error'] }], }, plugins: ['jest'], }; diff --git a/src/app.js b/src/app.js index af8226c..bc1665d 100644 --- a/src/app.js +++ b/src/app.js @@ -1,3 +1,5 @@ +/* eslint-disable no-console */ +/* eslint-disable no-unused-vars */ 'use strict'; const fs = require('fs');