better logging (fixes #100)

This commit is contained in:
Emile Nijssen 2021-11-12 21:20:28 +00:00
parent 5895b986fc
commit c19cb72b6d
2 changed files with 18 additions and 7 deletions

View file

@ -19,7 +19,7 @@ module.exports = class Util {
static promisify(fn) {
// eslint-disable-next-line func-names
return function(req, res) {
return function (req, res) {
Promise.resolve().then(async () => fn(req, res))
.then(result => {
if (res.headersSent) return;
@ -52,9 +52,16 @@ module.exports = class Util {
};
}
static async exec(cmd) {
// eslint-disable-next-line no-console
console.log(`$ ${cmd}`);
static async exec(cmd, {
log = true,
} = {}) {
if (typeof log === 'string') {
// eslint-disable-next-line no-console
console.log(`$ ${log}`);
} else if (log === true) {
// eslint-disable-next-line no-console
console.log(`$ ${cmd}`);
}
if (process.platform !== 'linux') {
return '';