Giter Site home page Giter Site logo

Comments (9)

reintroducing avatar reintroducing commented on June 25, 2024

Anyone? @shannonlal is this project still maintained?

from gulp-prompt.

shannonlal avatar shannonlal commented on June 25, 2024

@reintroducing can you provide a sample gulpfile to test

from gulp-prompt.

shannonlal avatar shannonlal commented on June 25, 2024

@reintroducing. The normal flow for it to exit is to return undefined. If you look under the examples directory at the file examples/chain-confirm-gulp.js that when the function stops when the chainFunction returns undefined.

var chainFunction = function ( options, resp ){
    console.log( 'Here is the selection ', resp);
    if( index <= 3){
        options.message = `Hello this is iteration ${index}`;
        index++;
        return options;
    }else{
        return; //Returning undefined stops the chaining process
    }
};

from gulp-prompt.

reintroducing avatar reintroducing commented on June 25, 2024

@shannonlal Here is an example: https://www.dropbox.com/s/2gngxpcpc7xi7ed/gulp-prompt-test.zip?dl=0

Just download, npm install, and npm start.

What i would expect to happen is that task2 and task3 still run because you're saying no to the current task in the sequence, that being that you don't want to copy the files for that task. its possible that i'm missing the point of this package, though, so just wanted to get a second pair of eyes on this.

from gulp-prompt.

shannonlal avatar shannonlal commented on June 25, 2024

@reintroducing gulp-prompt allows a user to prompt for user for input but in order to chain them you need to look at adding a chainFunction. See the example (Example Chaining Prompts: in ReadMe file). This will allow you to link multiple user inputs in sequence. With a chain function you essentially take control of the logic as to what questions to ask the user and when to end the sequence.

If I go to you initial question it looks like you want to ask the user four questions and do different behaviours based on the inputs. The chain function support will allow you to do this. It is essentially a recursive function that allows you to control the options (i.e. passed to the prompt) from prompt to prompt. The chain function will essentially intercept the result of each prompt, allow the developer to manipulate the options, and send them to the next prompt. When you return undefined it will exit the chain function.

Let me know if that answers your questions

from gulp-prompt.

reintroducing avatar reintroducing commented on June 25, 2024

@shannonlal I apologize, I should have been clearer in my prior post. I tried the chainer according to the example you originally pointed out and changed task1.js to the following:

const gulp = require('gulp');
const prompt = require('gulp-prompt');

const chainer = (options, resp) => {
    console.log('value: ', resp.val, typeof resp.val);

    if (resp.val) {
        return options;
    } else {
        return;
    }
};

gulp.task('task1', () => {
    return gulp.src('file.js')
        .pipe(prompt.confirm({
            message: 'Should we proceed to task 2?',
            default: true,
            chainFunction: chainer
        }, res => {
            console.log('RESULT:', res);
        }))
        .pipe(gulp.dest('dist'))
        .on('end', () => {
            console.log('im done');
        });
});

This essentially puts me in an endless loop if i answer Y and ends the sequence if I say n. I can't figure out how to get it to go to the next task no matter what is answered, but ideally i'd like to proceed to task2 regardless of the answer, and if they answer Y then go ahead and copy the file (the next pipe statement) and if n then don't copy but still move on in the original sequence in my default task. I also never see the RESULT log.

Does that make sense?

from gulp-prompt.

shannonlal avatar shannonlal commented on June 25, 2024

@reintroducing So you are trying to chain to independent gulp tasks. Is this correct? I use this on my internal project at work. I use run-sequence combined with gulp-prompt to collect parameters and then pass those parameters to other gulp tasks. Can you update the attached file to have task1 and task 2 defined and how you would expect to run them together.

from gulp-prompt.

reintroducing avatar reintroducing commented on June 25, 2024

@shannonlal I don't actually need task2 to take anything from task1. i just want task2 to run still if i say 'no' to task1. only thing i need is this, pseudo code:

if (yes to task1 then finish task1 and move to task2) else if (no to task1 then don't execute rest of task1 and move to task2) and so on until all tasks in the sequence have finished.

from gulp-prompt.

reintroducing avatar reintroducing commented on June 25, 2024

@shannonlal Is there anything else you need me to do to try and help track this down? Does my prior message make sense?

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.