🚀
Empathize
  • Introduction
  • Installation
  • API
    • Paths API
      • Directories
      • Paths
    • Filesystem API
      • Filesystem
    • Windows API
      • Windows
    • OS API
      • Process
      • Tray
      • IPC
      • Notification
      • Archive
      • Package
    • Network API
      • fetch
      • Domain
      • Downloader
    • Async API
      • promisify
    • Meta classes
      • Cache
      • Configs
      • Debug
  • Building application
Powered by GitBook
On this page
  1. API
  2. OS API

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');
});
PreviousArchiveNextNetwork API

Last updated 3 years ago