mirror of
https://github.com/ivabus/gui
synced 2025-06-08 00:00:27 +03:00
#55 add more success resolution on install
This commit is contained in:
parent
f1307333b3
commit
82c01b0818
2 changed files with 14 additions and 5 deletions
|
@ -20,7 +20,7 @@
|
||||||
let sortBy = 'popularity';
|
let sortBy = 'popularity';
|
||||||
let sortDirection: 'asc' | 'desc' = 'desc';
|
let sortDirection: 'asc' | 'desc' = 'desc';
|
||||||
|
|
||||||
const searchLimit = 5;
|
const searchLimit = 10;
|
||||||
|
|
||||||
const setPackages = (pkgs: GUIPackage[], isSearch?: boolean) => {
|
const setPackages = (pkgs: GUIPackage[], isSearch?: boolean) => {
|
||||||
packages = isSearch
|
packages = isSearch
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
packagesStore.subscribe((v) => {
|
packagesStore.subscribe((v) => {
|
||||||
allPackages = v;
|
allPackages = v;
|
||||||
setPackages(allPackages);
|
setPackages(allPackages);
|
||||||
if (!packagesIndex) {
|
if (!packagesIndex && allPackages.length) {
|
||||||
// dont remove or this can get crazy
|
// dont remove or this can get crazy
|
||||||
packagesIndex = new Fuse(allPackages, {
|
packagesIndex = new Fuse(allPackages, {
|
||||||
keys: ['name', 'full_name', 'desc']
|
keys: ['name', 'full_name', 'desc']
|
||||||
|
|
|
@ -92,17 +92,26 @@ async function installPackageCommand(full_name: string) {
|
||||||
const teaInstallCommand = new Command('tea-install', [`+${full_name}`, 'true']);
|
const teaInstallCommand = new Command('tea-install', [`+${full_name}`, 'true']);
|
||||||
teaInstallCommand.on('error', reject);
|
teaInstallCommand.on('error', reject);
|
||||||
|
|
||||||
const handleLineOutput = async (line: string) => {
|
const handleLineOutput = async (line: string | any) => {
|
||||||
const c = await child;
|
const c = await child;
|
||||||
if (line.includes('installed:')) {
|
if (line?.code === 0 || line.includes('installed:')) {
|
||||||
c.kill();
|
c.kill();
|
||||||
resolve(c.pid);
|
resolve(c.pid);
|
||||||
|
} else if (line?.code === 1) {
|
||||||
|
reject();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
teaInstallCommand.stdout.on('data', handleLineOutput);
|
teaInstallCommand.stdout.on('data', handleLineOutput);
|
||||||
teaInstallCommand.stderr.on('data', handleLineOutput);
|
teaInstallCommand.stderr.on('data', handleLineOutput);
|
||||||
|
teaInstallCommand.on('close', (line: string) => {
|
||||||
|
console.log('command closed!');
|
||||||
|
handleLineOutput(line || '');
|
||||||
|
});
|
||||||
|
teaInstallCommand.on('error', (line: string) => {
|
||||||
|
console.log('command error!', line);
|
||||||
|
handleLineOutput(line || '');
|
||||||
|
});
|
||||||
const child = teaInstallCommand.spawn();
|
const child = teaInstallCommand.spawn();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue