Giter Site home page Giter Site logo

Use prompt without pipe about gulp-prompt HOT 5 CLOSED

freyskeyd avatar freyskeyd commented on June 21, 2024 1
Use prompt without pipe

from gulp-prompt.

Comments (5)

yuricamara avatar yuricamara commented on June 21, 2024 6

Solved with Inquirer.js which is the library used by gulp-prompt

Example:

Both stop the gulp execution when the answer is 'no'.

//gulp-prompt
gulp.task('prompt', () => {
  const question = {
    message : 'Do you want to continue?(no)',
    default : false
  };

  return gulp.src('file')
    .pipe(prompt.confirm(question));
});
//Inquirer.js
gulp.task('prompt', () => {
  const question = [
    {
      type : 'confirm',
      name : 'continue',
      message : 'Do you want to continue?(no)',
      default : false
    }
  ];

  return inquirer.prompt(question).then(answer => {
    if (!answer.continue) {
      return process.exit (2);
    }
  });
});

from gulp-prompt.

strunkie30 avatar strunkie30 commented on June 21, 2024

I think that this Is not posible.
I use gulp.src('package.json') but it is ugly and slowing down the init.

from gulp-prompt.

codyrushing avatar codyrushing commented on June 21, 2024

I haven't really investigated why this works, but if you call .write() on the prompt stream, it will work:

gulp.task('install', function(){
  var prompter = gp_prompt.prompt(
    { type: 'input'
    , name: 'dbname'
    , message: 'Type your DB name:'
    },
    function (res){
      gulp.src('config./db.js')
      .pipe(gp_replace('_DBNAME_', res.dbname))
      .pipe(savefile())
    }
  )

  prompter.write()
  return prompter()
});

This probably has something to do with gulp not liking the Stream that Inquirer is returning

from gulp-prompt.

yuricamara avatar yuricamara commented on June 21, 2024

I miss this feature too.

I tried a confirm question with write(), @codyrushing . It didn't work as expected for me. The task was finished and then the question shown up.

from gulp-prompt.

shannonlal avatar shannonlal commented on June 21, 2024

I am going to close this issue out since yuricamara seems to have provided a solution. If there is still any outstanding questions or concerns please let me know.

from gulp-prompt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.