'use strict';

const { execFile } = require('child_process');

const exec = (...args) => {
    return new Promise((resolve, reject) => {
        execFile(...args, (err, stdout) => {
            if (err) {
                reject(err);
                return;
            }
            resolve(stdout);
        });
    });
};

module.exports = exec;

'use strict';

const util = require('util');
const childProcess = require('child_process');

const execFile = util.promisify(childProcess.execFile);

const exec = async (...args) => {
    const { stdout } = await execFile(...args);
    return stdout;
};

module.exports = exec;

Simplify with async and await
Simplify with async and await
