簡體   English   中英

如何在Gulp中使用Shell讀取?

[英]How to use shell read in gulp?

我正在嘗試建立一個gulp文件,要求用戶輸入(變量名),但無法正常工作。

我已經用完了gulp-shell回聲,它觸發了read命令並要求輸入,但是沒有保存該變量。

這是我的gulp代碼:

gulp.task('shell', shell.task([
  'echo hello, whats your name?',
  'read name',
  'echo oh hello, $name'
]));

輸出如下:

[14:51:47] Starting 'shell'...
hello, whats your name?
Foo
// ^ this is my input
oh hello,
[14:51:49] Finished 'shell' after 1.51 s

如您所見,我設置為'Foo'的名稱變量沒有得到輸出。

有任何想法嗎?

讀取輸入並在一行中回顯應能工作。 像這樣

gulp.task('shell', shell.task([
  'echo hello, whats your name?',
  'read name;echo oh hello, $name'
]));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM