sebhildebrandt / systeminformation

System Information Library for Node.JS
MIT License
2.64k stars 300 forks source link

powerShellStart that return Promise #911

Open xoxloviwan opened 1 month ago

xoxloviwan commented 1 month ago

Is your feature request related to a problem? Please describe. powerShellStart() and powerShellRelease() functions start and close a PowerShell process that may be running after some time (especialy on weak PC). Now in promise chain I can't get any status of running; and I can't know when PowerShell process was ready to work.

Describe the solution you'd like remake current functions or add new Promise-based variant of reailzation powerShellStart() that allow run this way:

     let specs = [ 'system', 'diskLayout', 'graphics' ];
     si.powerShellStartPromisify()
       .then(() => Promise.all(specs.map(async (item) => (info[item] = await si[item]())));

Describe alternatives you've considered Now I have to write something like this:

     let specs = [ 'system', 'diskLayout', 'graphics' ];
     new Promise((resolve) => {
            si.powerShellStart();
            setTimeout(() => resolve(), 1000);
     })
    .then(() => Promise.all(specs.map(async (item) => (info[item] = await si[item]())));
sebhildebrandt commented 1 month ago

@xoxloviwan This is a good idea! Will implement it the upcoming days.