Comments (9)
Anyone? @shannonlal is this project still maintained?
from gulp-prompt.
@reintroducing can you provide a sample gulpfile to test
from gulp-prompt.
@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.
@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.
@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.
@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.
@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.
@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.
@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)
- New Maintainer HOT 2
- Unit Testing HOT 1
- Add Code Coverage to the project HOT 1
- Include Code Metrics for NPM HOT 1
- Increment to v 1.0 of gulp-prompt HOT 1
- Release must use semver HOT 3
- SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode HOT 2
- Task finishing before I could use the result of the prompt HOT 9
- input masking HOT 2
- Netbeans output window HOT 8
- prompt.prompt() doesn't support chainFunction HOT 2
- Gulp task finishes but process never ends HOT 10
- Backdoored dependencies HOT 1
- Work only one prompt
- Not pouses pipe execution when prompt work HOT 1
- Not able to run an async task from callback of gulp-prompt
- How to properly integrate gulp-prompt in the pipe together with other plugins?
- gulp-prompt prevents use of sftp
- checkbox not support multiple defaults
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gulp-prompt.