#55 add more success resolution on install

This commit is contained in:
neil 2022-12-02 16:38:01 +08:00
parent f1307333b3
commit 82c01b0818
2 changed files with 14 additions and 5 deletions

View file

@ -20,7 +20,7 @@
let sortBy = 'popularity';
let sortDirection: 'asc' | 'desc' = 'desc';
const searchLimit = 5;
const searchLimit = 10;
const setPackages = (pkgs: GUIPackage[], isSearch?: boolean) => {
packages = isSearch
@ -42,7 +42,7 @@
packagesStore.subscribe((v) => {
allPackages = v;
setPackages(allPackages);
if (!packagesIndex) {
if (!packagesIndex && allPackages.length) {
// dont remove or this can get crazy
packagesIndex = new Fuse(allPackages, {
keys: ['name', 'full_name', 'desc']

View file

@ -92,17 +92,26 @@ async function installPackageCommand(full_name: string) {
const teaInstallCommand = new Command('tea-install', [`+${full_name}`, 'true']);
teaInstallCommand.on('error', reject);
const handleLineOutput = async (line: string) => {
const handleLineOutput = async (line: string | any) => {
const c = await child;
if (line.includes('installed:')) {
if (line?.code === 0 || line.includes('installed:')) {
c.kill();
resolve(c.pid);
} else if (line?.code === 1) {
reject();
}
};
teaInstallCommand.stdout.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();
});
}