MCPcopy Create free account
hub / github.com/easingthemes/ssh-deploy / deleteFile

Function deleteFile

src/helpers.js:48–69  ·  view source on GitHub ↗
({ dir, filename, isRequired })

Source from the content-addressed store, hash-verified

46};
47
48const deleteFile = ({ dir, filename, isRequired }) => {
49 validateDir(dir);
50 const filePath = join(dir, filename);
51
52 if (existsSync(filePath)) {
53 const message = `⚠️ [FILE] ${filePath} Required file exist.`;
54 handleError(message, isRequired);
55 return;
56 }
57
58 try {
59 console.log(`[FILE] Deleting ${filePath} file ...`);
60 unlink(filePath, (error) => {
61 if (error) {
62 throw new Error(error);
63 }
64 });
65 } catch (error) {
66 const message = `⚠️[FILE] Deleting file error. filePath: ${filePath}, message: ${error.message}`;
67 handleError(message, isRequired);
68 }
69};
70
71const validateRequiredInputs = (inputs) => {
72 const inputKeys = Object.keys(inputs);

Callers 1

remoteCmdFunction · 0.85

Calls 2

validateDirFunction · 0.85
handleErrorFunction · 0.70

Tested by

no test coverage detected