久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

  • <tfoot id='tVGQP'></tfoot>
    1. <legend id='tVGQP'><style id='tVGQP'><dir id='tVGQP'><q id='tVGQP'></q></dir></style></legend>

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

        在“管道"之間傳遞變量在吞咽

        Passing variables between quot;pipesquot; in Gulp(在“管道之間傳遞變量在吞咽)
        <i id='hwvWs'><tr id='hwvWs'><dt id='hwvWs'><q id='hwvWs'><span id='hwvWs'><b id='hwvWs'><form id='hwvWs'><ins id='hwvWs'></ins><ul id='hwvWs'></ul><sub id='hwvWs'></sub></form><legend id='hwvWs'></legend><bdo id='hwvWs'><pre id='hwvWs'><center id='hwvWs'></center></pre></bdo></b><th id='hwvWs'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='hwvWs'><tfoot id='hwvWs'></tfoot><dl id='hwvWs'><fieldset id='hwvWs'></fieldset></dl></div>

          • <bdo id='hwvWs'></bdo><ul id='hwvWs'></ul>
              <tbody id='hwvWs'></tbody>

            <legend id='hwvWs'><style id='hwvWs'><dir id='hwvWs'><q id='hwvWs'></q></dir></style></legend>

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

              <tfoot id='hwvWs'></tfoot>
                  本文介紹了在“管道"之間傳遞變量在吞咽的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我正在嘗試編寫一個 gulp 任務,該任務通過 gulp-prompt 插件獲取一些用戶輸入.但我無法將該輸入傳遞給其他例如:

                  I'm trying to write a gulp tasks that takes some user input via the gulp-prompt plugin. But I'm having trouble passing that input along to other eg:

                  gulp.task('userinput', function(){
                  
                      var myVar = 'MONKEY';
                  
                      gulp.src('./templates/_component.*')
                      .pipe(prompt.prompt([
                          {
                              type: 'input',
                              name: 'userInput',
                              message: 'Say something'
                          }
                      ], function(res){
                          myVar = res.userInput;
                      }))
                      .pipe(prompt.confirm('You said ' + myVar));
                  });
                  

                  假設我在提示符處輸入 hello,我希望確認會說 You said Hello,但它說的是 You said MONKEY.

                  Assuming I enter hello at the prompt, I was expecting the confirmation to say You said Hello, but it says You said MONKEY.

                  Gulp 可以做到這一點嗎?

                  Is this possible with Gulp?

                  推薦答案

                  這里的問題是你正在創(chuàng)建第二個提示 ('You said ' + myVar) before 第一個提示已執(zhí)行:

                  The issue here is that you are creating the second prompt ('You said ' + myVar) before the first prompt has been executed:

                  1. myVar 設置為 'MONKEY'
                  2. 創(chuàng)建信息流
                  1. Set myVar to 'MONKEY'
                  2. Create streams
                  1. 創(chuàng)建 src 流,這是異步的
                  2. 創(chuàng)建第一個提示,并將其添加到 src 流中
                  3. 使用 myVar 的當前值創(chuàng)建第二個提示,并將其添加到第一個提示流中
                  1. Create src stream, which is asynchronous
                  2. Create first prompt, and add it to the src stream
                  3. Create second prompt using current value of myVar, and add it to the first prompt stream

                • 現(xiàn)在才處理執(zhí)行的流

                • Only now are the streams executed processed

                  1. 加載源
                  2. 運行第一個提示,設置myVar
                  3. 使用之前生成的消息運行第二個提示

                • <小時>

                  如果您想將其全部保留為單個流,唯一的解決方案是在允許閉包(函數(shù))的東西中使用變量.一些插件已經(jīng)接受閉包作為參數(shù),但大多數(shù)不接受.


                  The only solution if you want to keep it all as a single stream is to use the variable within something that allows for a closure (function). Some plugins already accept a closure as an argument, but most don't.

                  將流包裝在閉包中的一種解決方案是 gulp-tap,它不是專門為這種情況設計的,但應該可以工作.它看起來像這樣:

                  One solution to wrap a stream in a closure that would work here is gulp-tap, which isn't designed for this scenario specifically, but should work. it looks like this:

                  var tap = require('gulp-tap');
                  
                  //...
                  
                  gulp.task('userinput', function(){
                  
                      var myVar = 'MONKEY';
                  
                      gulp.src('./templates/_component.*')
                      .pipe(prompt.prompt([
                          {
                              type: 'input',
                              name: 'userInput',
                              message: 'Say something'
                          }
                      ], function(res){
                          myVar = res.userInput;
                      }))
                      .pipe(tap(function(file, t) {
                          // format is t.through(stream-function, [arguments...])
                          return t.through(prompt.confirm, ['You said ' + myVar]);
                      });
                  });
                  

                  因為它被包裝在一個閉包中,并且針對每個文件進行評估,所以它將獲取變量的 current 值.但是,因為它適用于每個文件,所以您會看到處理 每個 文件的提示一次.

                  Because this is wrapped in a closure, and evaluated for each file, it will pick up the current value for the variable. However, because it works on each file, you'll see the prompt once for each file processed.

                  更好的解決方案是將您的任務分成多個相互依賴的任務.看起來像這樣:

                  An better solution would be to separate your task into multiple, dependent tasks. That would look something like this:

                  var myVar = 'MONKEY';
                  
                  gulp.task('userinput1', function(){
                  
                      return gulp.src('./templates/_component.*', {read: false})
                          .pipe(prompt.prompt([
                              {
                                  type: 'input',
                                  name: 'userInput',
                                  message: 'Say something'
                              }
                          ], function(res){
                              myVar = res.userInput;
                          }));
                  });
                  
                  gulp.task('userinput', ['userinput1'], function() {
                      return gulp.src('./templates/_component.*')
                          .pipe(prompt.confirm('You said ' + myVar));
                  });
                  

                  現(xiàn)在第一個任務 (userinput1) 將運行并完成第二個任務被處理 (userinput2),所以變量將是設置正確.

                  Now the first task (userinput1) will run and complete before the second one is processed (userinput2), so the variable will be set correctly.

                  注意:確保從您的任務中return流,否則它們會被同步處理,并且您的變量不會被設置.

                  NOTE: Make sure you return the stream from your tasks, otherwise they are processed synchronously, and your variable won't get set.

                  <小時>

                  最后,完全放棄 gulp-prompt 任務可能更有意義,因為它與流沒有太大關(guān)系.您最好在任務中直接使用 Node JavaScript 來收集用戶的輸入(最好以同步方式),然后在 gulp-stream 中處理您的文件.


                  Finally, it might make more sense to forgo the gulp-prompt task altogether, because it doesn't really have much to do with the stream. You'd probably be better off using straight Node JavaScript within your task to gather the user's input (preferably in a synchronous manner), then processing your files in a gulp-stream after that.

                  這篇關(guān)于在“管道"之間傳遞變量在吞咽的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 傳播運算符上的意外令牌)
                  Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以將標志傳遞給 Gulp 以使其以不同的方式運行任務?)
                  Why do we need to install gulp globally and locally?(為什么我們需要在全局和本地安裝 gulp?)
                  How to run Gulp tasks sequentially one after the other(如何一個接一個地依次運行 Gulp 任務)
                  Stylesheet not loaded because of MIME-type(由于 MIME 類型而未加載樣式表)
                  Visual Studio 2015 crashes when opening Javascript files(打開 Javascript 文件時 Visual Studio 2015 崩潰)
                    <tbody id='5A7OI'></tbody>

                  <small id='5A7OI'></small><noframes id='5A7OI'>

                        <bdo id='5A7OI'></bdo><ul id='5A7OI'></ul>
                        <legend id='5A7OI'><style id='5A7OI'><dir id='5A7OI'><q id='5A7OI'></q></dir></style></legend>

                          • <i id='5A7OI'><tr id='5A7OI'><dt id='5A7OI'><q id='5A7OI'><span id='5A7OI'><b id='5A7OI'><form id='5A7OI'><ins id='5A7OI'></ins><ul id='5A7OI'></ul><sub id='5A7OI'></sub></form><legend id='5A7OI'></legend><bdo id='5A7OI'><pre id='5A7OI'><center id='5A7OI'></center></pre></bdo></b><th id='5A7OI'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5A7OI'><tfoot id='5A7OI'></tfoot><dl id='5A7OI'><fieldset id='5A7OI'></fieldset></dl></div>
                            <tfoot id='5A7OI'></tfoot>

                          • 主站蜘蛛池模板: 国产精品一区二区在线播放 | 久久久久久国产精品免费免费狐狸 | 99re在线视频| 在线观看亚洲专区 | 国产激情在线观看视频 | 国产精品久久国产精品久久 | 国产成人精品免高潮在线观看 | 亚洲国产精品99久久久久久久久 | 九九热精品视频在线观看 | 国产一区二区三区久久久久久久久 | 久久久精品影院 | 在线观看免费av片 | 69xxx免费| 亚洲日日夜夜 | 欧美日韩三级 | 99久久精品一区二区毛片吞精 | 精品久久久久久久久久久下田 | 中文字幕 欧美 日韩 | 国产精品久久久久久久久久妞妞 | 九九热国产视频 | 日韩在线中文字幕 | 久久久久久久久久久久久久久久久久久久 | 免费在线播放黄色 | 日韩欧美国产精品一区 | 久久久久久久久99 | 国产精品入口麻豆www | 国产精品一区二区久久久久 | 精品国产乱码久久久久久蜜柚 | 性在线 | 精品免费国产视频 | 国产精品久久久久久福利一牛影视 | 很黄很污的网站 | 国产一级视频在线观看 | 日本不卡一区 | 国产欧美日韩综合精品一区二区 | 亚洲国产成人精品女人 | 亚洲精品一区二区二区 | 天天影视亚洲综合网 | 国产ts人妖系列高潮 | 亚洲精品18| 91精品国产综合久久久久久丝袜 |