feat: apply deleteFile function to remoteCmd

This commit is contained in:
Emmanuel Isenah 2024-03-17 22:19:44 +01:00
parent 1befdb1c6b
commit b82eced457

View File

@ -1,7 +1,7 @@
const { exec } = require('child_process'); const { exec } = require('child_process');
const crypto = require('crypto'); const crypto = require('crypto');
const { sshServer, githubWorkspace, remotePort } = require('./inputs'); const { sshServer, githubWorkspace, remotePort } = require('./inputs');
const { writeToFile } = require('./helpers'); const { writeToFile, deleteFile } = require('./helpers');
const handleError = (message, isRequired, callback) => { const handleError = (message, isRequired, callback) => {
if (isRequired) { if (isRequired) {
@ -30,6 +30,8 @@ const remoteCmd = async (content, privateKeyPath, isRequired, label) => new Prom
} else { } else {
const limited = data.substring(0, dataLimit); const limited = data.substring(0, dataLimit);
console.log('✅ [CMD] Remote script executed. \n', limited, stderr); console.log('✅ [CMD] Remote script executed. \n', limited, stderr);
deleteFile({ dir: githubWorkspace, filename });
console.log('✅ [FILE] Script file deleted.');
resolve(limited); resolve(limited);
} }
} }