Skip to content

Commit

Permalink
Added touch command
Browse files Browse the repository at this point in the history
  • Loading branch information
hemanth-hk committed Mar 31, 2020
1 parent 044a404 commit 1c894a4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions commands/touch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var fs = require("fs");

function touch(path, FileName = "New") {
var new_path = path.concat(FileName);

fs.open(new_path, "wx", (err, fd) => {
if (err) {
console.log("File cannot be created");
} else {
console.log(`File ${FileName} has been created succesfully`);
}
fs.close(fd, (err) => {
if (err) {
console.log("File cannot be closed");
}
});
});
};

module.exports = touch;

0 comments on commit 1c894a4

Please sign in to comment.