Search code examples
javascriptbashshellgulpgulp-shell

How to use shell read in gulp?


I'm trying to set up a gulp file which asks for input from the user (for a variable name), but I can't get it working.

I've got gulp-shell echo-ing fine, and it triggers the read command and asks for the input, but the variable isn't saved.

Here's my gulp code:

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

the output is as follows:

[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

As you can see, the name variable, which I set to 'Foo' doesn't get output.

Any ideas?


Solution

  • Reading the input and echo'ing in one line should work. Something like this

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