<bdo id='nyIT4'></bdo><ul id='nyIT4'></ul>

  • <small id='nyIT4'></small><noframes id='nyIT4'>

    <i id='nyIT4'><tr id='nyIT4'><dt id='nyIT4'><q id='nyIT4'><span id='nyIT4'><b id='nyIT4'><form id='nyIT4'><ins id='nyIT4'></ins><ul id='nyIT4'></ul><sub id='nyIT4'></sub></form><legend id='nyIT4'></legend><bdo id='nyIT4'><pre id='nyIT4'><center id='nyIT4'></center></pre></bdo></b><th id='nyIT4'></th></span></q></dt></tr></i><div id='nyIT4'><tfoot id='nyIT4'></tfoot><dl id='nyIT4'><fieldset id='nyIT4'></fieldset></dl></div>

  • <legend id='nyIT4'><style id='nyIT4'><dir id='nyIT4'><q id='nyIT4'></q></dir></style></legend>
    <tfoot id='nyIT4'></tfoot>

        我如何保证在我的应用程序中一次性使用 gulp?

        时间:2023-05-29
        <legend id='Tv9DA'><style id='Tv9DA'><dir id='Tv9DA'><q id='Tv9DA'></q></dir></style></legend>
            <tbody id='Tv9DA'></tbody>
          • <bdo id='Tv9DA'></bdo><ul id='Tv9DA'></ul>
            • <i id='Tv9DA'><tr id='Tv9DA'><dt id='Tv9DA'><q id='Tv9DA'><span id='Tv9DA'><b id='Tv9DA'><form id='Tv9DA'><ins id='Tv9DA'></ins><ul id='Tv9DA'></ul><sub id='Tv9DA'></sub></form><legend id='Tv9DA'></legend><bdo id='Tv9DA'><pre id='Tv9DA'><center id='Tv9DA'></center></pre></bdo></b><th id='Tv9DA'></th></span></q></dt></tr></i><div id='Tv9DA'><tfoot id='Tv9DA'></tfoot><dl id='Tv9DA'><fieldset id='Tv9DA'></fieldset></dl></div>

              <small id='Tv9DA'></small><noframes id='Tv9DA'>

              <tfoot id='Tv9DA'></tfoot>

                  本文介绍了我如何保证在我的应用程序中一次性使用 gulp?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  作为我正在编写的一个小程序的一部分,我想使用 gulp 将大量文件转换为 markdown.这不是独立于程序的构建步骤的一部分.这是程序的一部分.所以我没有使用 gulpfile 来处理这个问题.

                  As part of a small program I'm writing, I would like to use gulp to convert a large set of a files to markdown. This is not part of a build step separate from the program. It's a part of the program. So I'm not using a gulpfile to handle this.

                  问题是,因为它是异步的,所以我想使用一个 Promise,它会在 gulp 任务完成时提醒我.

                  The problem is, since it's async, I want to use a promise which will alert me when the gulp task is finished.

                  这样的东西是理想的:

                  io.convertSrc = function() {
                    var def = q.defer();
                  
                    gulp.src(src + '/*.md')
                      .pipe(marked({}))
                      .pipe(gulp.dest(dist), function() {
                        def.resolve('We are done!');
                      });
                  
                      return def.promise;
                  }
                  

                  pipe 不接受回调.我怎么能处理这个?感谢您的帮助,我对 gulp 有点陌生.

                  But pipe doesn't take a callback. How could I handle this? Thanks for your help, I'm somewhat new to gulp.

                  推荐答案

                  gulp 中的一切都是一个流,所以你可以只监听 enderror 事件.

                  Everything in gulp is a stream, so you can just listen for the end and error events.

                  io.convertSrc = function() {
                    var def = q.defer();
                    gulp.src(src + '/*.md')
                      .pipe(marked({}))
                      .pipe(gulp.dest(dist))
                      .on('end', function() {
                        def.resolve();
                      })
                      .on('error', def.reject);
                    return def.promise;
                  }
                  

                  顺便说一句,Q 1.0 不再被开发(除了一些修复)并且将完全不兼容Q 2.0;我推荐 Bluebird 作为替代方案.

                  As an aside, Q 1.0 is no longer developed (aside from a few fixes here and there) and will be wholly incompatible with Q 2.0; I'd recommend Bluebird as an alternative.

                  还值得一提的是,NodeJS 0.12 及更高版本已内置 ES6 承诺(不需要 --harmony 标志),因此如果您不寻求向后兼容性,您可以使用它们来代替..

                  Also worth mentioning that NodeJS 0.12 onwards has ES6 promises built into it (no --harmony flag necessary) so if you're not looking for backwards compatibility you can just use them instead..

                  io.convertSrc = function() {
                    return new Promise(function(resolve, reject) {
                      gulp.src(src + '/*.md')
                        .pipe(marked({}))
                        .pipe(gulp.dest(dist))
                        .on('end', resolve)
                        .on('error', reject);
                    });
                  };
                  

                  这篇关于我如何保证在我的应用程序中一次性使用 gulp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:启动时打开 Karma debug.html 页面 下一篇:如何同时使用“gulp-babel"和“gulp-browserify&qu

                  相关文章

                  最新文章

                    <small id='pKchO'></small><noframes id='pKchO'>

                  1. <legend id='pKchO'><style id='pKchO'><dir id='pKchO'><q id='pKchO'></q></dir></style></legend>
                  2. <i id='pKchO'><tr id='pKchO'><dt id='pKchO'><q id='pKchO'><span id='pKchO'><b id='pKchO'><form id='pKchO'><ins id='pKchO'></ins><ul id='pKchO'></ul><sub id='pKchO'></sub></form><legend id='pKchO'></legend><bdo id='pKchO'><pre id='pKchO'><center id='pKchO'></center></pre></bdo></b><th id='pKchO'></th></span></q></dt></tr></i><div id='pKchO'><tfoot id='pKchO'></tfoot><dl id='pKchO'><fieldset id='pKchO'></fieldset></dl></div>

                  3. <tfoot id='pKchO'></tfoot>
                        <bdo id='pKchO'></bdo><ul id='pKchO'></ul>