7
7
7GIT2020-11-19 09:27:58
JavaScript
7GIT, 2020-11-19 09:27:58

Why doesn't console.log show up like gulp ends a function?

What is the correct way to write console.log('END') after gulp.task completes?

const { src, dest, series } = require('gulp');
const sass = require('gulp-sass');

function OPTcompileSCSS() {
  console.log('START');
  return src('src/assets/scss/**/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(dest('build/test/assets/css/'));
  // console.log('END'); // не работает, не отображается в консоли.
}

exports.OPTcompileSCSS = OPTcompileSCSS;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
ettychel, 2020-11-19
@7GIT

You are trying to console.log after the function has exited.
You should wrap the call to the function itself in console.log.

console.log('START')
OPTcompileSCSS()
console.log('END')

Well, most likely you want to measure the execution time of a function, use console.time(label) and console.timeEnd(label) for this
console.time('OPTcompileSCSS')
OPTcompileSCSS()
console.timeEnd('OPTcompileSCSS')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question