Skip to content

Commit f7160b5

Browse files
committed
feat: add copy file logic
1 parent ff435f3 commit f7160b5

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/app.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,27 @@
1+
/* eslint-disable no-console */
2+
13
'use strict';
4+
5+
import fsp from 'node:fs/promises';
6+
7+
async function main() {
8+
const argv = process.argv.slice(2);
9+
10+
if (argv.length < 2 || argv[0] === argv[1]) {
11+
return;
12+
}
13+
14+
const [filePath, filePathCopy] = argv;
15+
16+
try {
17+
const fileData = await fsp.readFile(filePath, 'utf8');
18+
19+
await fsp.writeFile(filePathCopy, fileData).catch((error) => {
20+
console.log(error);
21+
});
22+
} catch (error) {
23+
console.log(error);
24+
}
25+
}
26+
27+
main();

0 commit comments

Comments
 (0)