Package

Package.exists(name)

import { Package, Notification, fetch, promisify } from '@empathize/framework';

promisify(async () => {
    // curl required by fetch
    if (await Package.exists('curl'))
    {
        const header = await fetch('example.com');
    
        // something interesting
    }
    
    // libnotify required by Notification
    else if (await Package.exists('libnotify'))
    {
        Notification.show({
            title: 'An error appeared during fetching data...',
            body: 'You don\'t have curl package to fetch data from the internet. Please, download it',
            icon: '/absolute/path/to/my/icon.png'
        });
    }
    
    else console.error('An error appeared during fetching data from the internet: curl package is required');
});

Last updated