Skip to content

Commit

Permalink
fix task decorator logs
Browse files Browse the repository at this point in the history
  • Loading branch information
dergachevm committed Oct 1, 2024
1 parent 603db23 commit 139337e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 92 deletions.
92 changes: 1 addition & 91 deletions .ancros/utils/task-decorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,18 @@ const taskDecorator = (name, task) => {
// Streams
if (t?.pipe) {
t.on('end', (end) => {
// console.log('end', end);
});

t.on('data', (data) => {
// console.log('data', data);
});

t.on('pipe', (pipe) => {
// console.log('pipe', pipe);
finish(name, startTime);
done();
});

t.on('close', (close) => {
// console.log('close', name, close);
finish(name, startTime);
// finish(name, startTime);
done();
});

Expand All @@ -59,7 +55,6 @@ const taskDecorator = (name, task) => {
});

t.on('finish', async (f) => {
// console.log('finish', name, f);
finish(name, startTime);
done();
});
Expand All @@ -77,89 +72,4 @@ const taskDecorator = (name, task) => {
}
}

const taskDecoratorPromise = (name, task) => {
return async (done) => {
const startTime = performance.now();

start(name);
console.log('task ' + name, task);
const t = await task(done);
console.log('task', task);

/* return t?.on('finish', () => {
finish(name, startTime);
done();
}); */

finish(name, startTime);

return done;
/*
start(name);
const t = task(() => {
finish(name, startTime);
done();
});
t?.pipe && t.on('error', (err) => {
console.log('PIPE', err);
finish(name, startTime);
done();
});
t?.pipe && t.on('finish', () => {
finish(name, startTime);
done();
});
t?.then && t.then(() => {
finish(name, startTime);
done();
})
t?.catch && t.catch((err) => {
console.log('CATCH', err);
finish(name, startTime);
done();
}) */
}
}

export default taskDecorator;
export {
taskDecoratorPromise
};


/* const dots = {
current: 0,
interval: 80,
frames: [
'⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'
]
}
function loadingAnimation(
text = "test",
// chars = ["⠙", "⠘", "⠰", "⠴", "⠤", "⠦", "⠆", "⠃", "⠋", "⠉"],
chars = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],
delay = 100
) {
let x = 0;
return setInterval(function() {
process.stdout.write("\r" + chars[x++] + " " + text);
x = x % chars.length;
}, delay);
}
const spin = (message) => {
process.stdout.write(dots.frames[dots.current % 10] + ' ' + message);
process.stdout.clearLine(0);
process.stdout.cursorTo(0);
process.stdout.write(""); // end the line
}
loadingAnimation();
*/
2 changes: 1 addition & 1 deletion gulp.ancros.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as dartSass from 'sass';
import gulpSass from 'gulp-sass';
import 'dotenv/config';
import liveReloader from './.ancros/live-reloader/server.js';
import task, { taskDecoratorPromise } from './.ancros/utils/task-decorator.js';
import task from './.ancros/utils/task-decorator.js';
import chalk from 'chalk';
import findFreePort from './.ancros/utils/find-free-port.js';
import { renderStaticTask } from './.ancros/render.js';
Expand Down

0 comments on commit 139337e

Please sign in to comment.