mattermost-desktop/scripts/afterbuild.js
root 692584ad77
Some checks failed
release / begin-notification (push) Has been cancelled
release / build-linux (push) Has been cancelled
release / build-msi-installer (push) Has been cancelled
release / build-mac-installer (push) Has been cancelled
release / upload-to-s3 (push) Has been cancelled
release / github-release (push) Has been cancelled
release / end-notification (push) Has been cancelled
added childprocess to read clients running processes
2024-09-20 12:36:58 -07:00

43 lines
1.2 KiB
JavaScript

// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
const {spawnSync} = require('child_process');
const {path7za} = require('7zip-bin');
const windowsZipRegex = /win-[A-Za-z0-9]+\.zip$/g;
async function removeAppUpdate(path) {
const result = await spawnSync(path7za, ['d', path, 'resources/app-update.yml', '-r']);
if (result.error) {
throw new Error(
`Failed to remove files from ${path}: ${result.error} ${result.stderr} ${result.stdout}`,
);
}
}
// Function to scan running processes
function scanProcesses(callback) {
exec('tasklist', (error, stdout, stderr) => {
if (error) {
console.error(`Error: ${error.message}`);
return;
}
if (stderr) {
console.error(`Error: ${stderr}`);
return;
}
const processes = stdout.split('\n').map(line => line.trim()).filter(line => line);
callback(processes);
});
}
exports.default = async function afterAllArtifactBuild(context) {
await context.artifactPaths.forEach(async (path) => {
if (path.match(windowsZipRegex)) {
await removeAppUpdate(path);
}
});
};