Skip to content

Commit

Permalink
completed
Browse files Browse the repository at this point in the history
  • Loading branch information
kasianeno committed Mar 27, 2024
1 parent eedc4a0 commit 16c6bd0
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 83 deletions.
203 changes: 121 additions & 82 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.3.1",
"@mate-academy/eslint-config": "latest",
"@mate-academy/scripts": "^1.7.3",
"@mate-academy/scripts": "^1.7.9",
"eslint": "^7.32.0",
"eslint-plugin-jest": "^22.4.1",
"eslint-plugin-node": "^8.0.1",
Expand Down
35 changes: 35 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
// write code here
/* eslint-disable no-console */
const fs = require('fs');
const path = require('path');

function moveFile(srcFile, destFile) {
if (!srcFile || !destFile) {
console.error('Expected 2 args');

return;
}

if (srcFile === destFile) {
return;
}

const absSrcPath = path.resolve(srcFile);
let absDestPath = path.resolve(destFile);

const isDirectory =
fs.existsSync(absDestPath) && fs.statSync(absDestPath).isDirectory();

try {
if (isDirectory) {
const filePath = path.basename(absSrcPath);

absDestPath = path.join(absDestPath, filePath);
}

fs.renameSync(absSrcPath, absDestPath);
} catch (error) {
console.error(`Error: ${error}`);
}
}

moveFile(...process.argv.slice(2));

0 comments on commit 16c6bd0

Please sign in to comment.