Why is consolelog not showing as function completion in gulp?

  • 0
    How do I write console.log ('END') correctly 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;
    JavaScript Anonymous, Apr 23, 2020

  • 1 Answers
  • 0
    You are trying to execute console.log after the function exits.

    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')
    Connor Mosley

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!