From 0891f9c8565b3294bd6c46c485ce629e5fc3ac9f Mon Sep 17 00:00:00 2001 From: Mykhailo Date: Fri, 26 Jan 2024 16:46:50 +0200 Subject: [PATCH 1/2] add task solution --- src/app.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/app.js b/src/app.js index ad9a93a..6380afa 100644 --- a/src/app.js +++ b/src/app.js @@ -1 +1,19 @@ 'use strict'; + +const fs = require('fs'); + +const copyFile = (src, dest) => { + if (src === dest || !src || !dest) { + return; + } + + const stats = fs.statSync(src); + + if (!stats.isFile()) { + return; + } + + fs.copyFileSync(src, dest); +}; + +copyFile(...process.argv.slice(2)); From d58240eccaff8d9322efa08324bb07aa21168f1f Mon Sep 17 00:00:00 2001 From: Misha Lehotskyi <78600268+MishaLehotskyi@users.noreply.github.com> Date: Fri, 26 Jan 2024 20:03:13 +0200 Subject: [PATCH 2/2] Update src/app.js Co-authored-by: Vadym Voiedilo <108701488+vadiimvooo@users.noreply.github.com> --- src/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app.js b/src/app.js index 6380afa..cd01b55 100644 --- a/src/app.js +++ b/src/app.js @@ -4,7 +4,7 @@ const fs = require('fs'); const copyFile = (src, dest) => { if (src === dest || !src || !dest) { - return; + throw new Error('Unable to copy file'); } const stats = fs.statSync(src);