forked from coolaj86/telebit.js
		
	update question asking, fix some config stuff
This commit is contained in:
		
							parent
							
								
									e57485f794
								
							
						
					
					
						commit
						d40e86cc56
					
				| @ -117,6 +117,7 @@ function askForConfig(answers, mainCb) { | |||||||
|       console.info(""); |       console.info(""); | ||||||
|       // TODO attempt to read email from npmrc or the like?
 |       // TODO attempt to read email from npmrc or the like?
 | ||||||
|       rl.question('email: ', function (email) { |       rl.question('email: ', function (email) { | ||||||
|  |         email = /@/.test(email) && email.trim(); | ||||||
|         if (!email) { askEmail(cb); return; } |         if (!email) { askEmail(cb); return; } | ||||||
|         answers.email = email.trim(); |         answers.email = email.trim(); | ||||||
|         answers.agree_tos = true; |         answers.agree_tos = true; | ||||||
| @ -170,7 +171,30 @@ function askForConfig(answers, mainCb) { | |||||||
|     } |     } | ||||||
|   ]; |   ]; | ||||||
|   var standardSet = [ |   var standardSet = [ | ||||||
|     function askNewsletter(cb) { |     function askUpdates(cb) { | ||||||
|  |       var options = [ 'newsletter', 'important', 'required' ]; | ||||||
|  |       if (-1 !== options.indexOf(answers.updates)) { cb(); return; } | ||||||
|  |       console.info(""); | ||||||
|  |       console.info(""); | ||||||
|  |       console.info("What updates would you like to receive? (" + options.join(',') + ")"); | ||||||
|  |       console.info(""); | ||||||
|  |       rl.question('email preference (default: important): ', function (updates) { | ||||||
|  |         updates = (updates || '').trim().toLowerCase(); | ||||||
|  |         if (!updates) { updates = 'important'; } | ||||||
|  |         if (-1 === options.indexOf(updates)) { askUpdates(cb); return; } | ||||||
|  | 
 | ||||||
|  |         if ('newsletter' === updates) { | ||||||
|  |           answers.newsletter = true; | ||||||
|  |           answers.communityMember = true; | ||||||
|  |         } else if ('important' === updates) { | ||||||
|  |           answers.communityMember = true; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         setTimeout(cb, 250); | ||||||
|  |       }); | ||||||
|  |     } | ||||||
|  |     /* | ||||||
|  |   , function askNewsletter(cb) { | ||||||
|       if (answers.newsletter) { cb(); return; } |       if (answers.newsletter) { cb(); return; } | ||||||
|       console.info(""); |       console.info(""); | ||||||
|       console.info(""); |       console.info(""); | ||||||
| @ -196,6 +220,7 @@ function askForConfig(answers, mainCb) { | |||||||
|         setTimeout(cb, 250); |         setTimeout(cb, 250); | ||||||
|       }); |       }); | ||||||
|     } |     } | ||||||
|  |     */ | ||||||
|   , function askTelemetry(cb) { |   , function askTelemetry(cb) { | ||||||
|       if (answers.telemetry) { cb(); return; } |       if (answers.telemetry) { cb(); return; } | ||||||
|       console.info(""); |       console.info(""); | ||||||
| @ -280,7 +305,11 @@ function askForConfig(answers, mainCb) { | |||||||
| 
 | 
 | ||||||
|   function next() { |   function next() { | ||||||
|     var q = nextSet.shift(); |     var q = nextSet.shift(); | ||||||
|     if (!q) { if (useTty) { stdin.close(); } rl.close(); mainCb(null, answers); return; } |     if (!q) { | ||||||
|  |       if (useTty) { stdin.end(); stdin.close(); } | ||||||
|  |       rl.close(); mainCb(null, answers); | ||||||
|  |       return; | ||||||
|  |     } | ||||||
|     q(next); |     q(next); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -75,9 +75,11 @@ var controlServer; | |||||||
| 
 | 
 | ||||||
| var tun; | var tun; | ||||||
| function serveControls() { | function serveControls() { | ||||||
|   if (!state.config.disable && state.config.relay && (state.config.token || state.config.agreeTos)) { |   if (!state.config.disable) { | ||||||
|  |     if (state.config.relay && (state.config.token || state.config.agreeTos)) { | ||||||
|       tun = rawTunnel(); |       tun = rawTunnel(); | ||||||
|     } |     } | ||||||
|  |   } | ||||||
|   controlServer = http.createServer(function (req, res) { |   controlServer = http.createServer(function (req, res) { | ||||||
|     var opts = url.parse(req.url, true); |     var opts = url.parse(req.url, true); | ||||||
|     if (opts.query._body) { |     if (opts.query._body) { | ||||||
| @ -116,7 +118,7 @@ function serveControls() { | |||||||
|       }); |       }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (/\binit\b/.test(opts.path)) { |     if (/\b(init|config)\b/.test(opts.path)) { | ||||||
|       var conf = {}; |       var conf = {}; | ||||||
|       var fresh; |       var fresh; | ||||||
|       if (!opts.body) { |       if (!opts.body) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user