【问题标题】:OS notification in gulp-notify doesn't workgulp-notify 中的操作系统通知不起作用
【发布时间】:2020-03-10 14:16:06
【问题描述】:

大家好

我有一个自定义错误处理程序,它应该使用 gulp-notify 显示通知,然后在 sass 编译器失败时将其记录在控制台中。

var errorHandler = function(error) {
    notify.onError({
        title: 'Task Failed [' + error.plugin + ']',
        message: 'Sass ha ricontrato un errore',
        sound: true
    })(error);
    this.emit('end');
    notify("Files has an error");
    return notify().write(error);
};

function scss() {
    return src("product-template/Product Template/assets/styles/scss/**/*.scss")
        .pipe(sourcemaps.init())
        .pipe(sass())
        .on("error", errorHandler)
        .pipe(prefix(/*{grid: "no-autoplace"}*/))
        .pipe(sourcemaps.write("./"))
        .pipe(dest("./product-template/Product Template/assets/styles/css/"))
        .pipe(browserSync.stream());
}

预期行为

这段代码应该在 sass 出现错误时显示带有标题、正文 ecc 的通知 Os (windows) 消息 (toast)

真实行为

这段代码实际上不起作用,它只会在控制台中记录错误消息。不要出现预期的行为


配置有错误吗?

【问题讨论】:

    标签: css sass gulp gulp-notify


    【解决方案1】:

    试试这个。

    function scss() {
        return src("product-template/Product Template/assets/styles/scss/**/*.scss")
            .pipe(sourcemaps.init())
            .pipe(sass())
            .on("error", function(error) {
                notify.onError({
                    title: 'Task Failed [' + error.plugin + ']',
                    message: 'Sass ha ricontrato un errore',
                    sound: true
                })(error);
                this.emit('end');
                notify("Files has an error");
                return notify().write(error);
            })
            .pipe(prefix(/*{grid: "no-autoplace"}*/))
            .pipe(sourcemaps.write("./"))
            .pipe(dest("./product-template/Product Template/assets/styles/css/"))
            .pipe(browserSync.stream());
    }
    

    【讨论】:

    • 我试过你的答案,但没有任何改变。我认为问题出在 Windows 中,因为某些时候我会收到 gulp 的通知,而某些时候什么都没有
    • 有趣,我的答案在我的机器上运行正常,但我在 Mac 上,很可能是 Windows 问题。
    猜你喜欢
    • 2013-05-21
    • 1970-01-01
    • 2014-05-21
    • 1970-01-01
    • 1970-01-01
    • 2015-10-04
    • 2017-02-23
    • 1970-01-01
    • 2011-06-03
    相关资源
    最近更新 更多