mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	merge upstream/master
This commit is contained in:
		| @@ -38,7 +38,7 @@ RED.library = (function() { | ||||
|                             li.className = "dropdown-submenu pull-left"; | ||||
|                             a = document.createElement("a"); | ||||
|                             a.href="#"; | ||||
|                             var label = i.replace(/^node-red-contrib-/,"").replace(/^node-red-node-/,"").replace(/-/," ").replace(/_/," "); | ||||
|                             var label = i.replace(/^@.*\//,"").replace(/^node-red-contrib-/,"").replace(/^node-red-node-/,"").replace(/-/," ").replace(/_/," "); | ||||
|                             a.innerHTML = label; | ||||
|                             li.appendChild(a); | ||||
|                             li.appendChild(buildMenu(data.d[i],root+(root!==""?"/":"")+i)); | ||||
|   | ||||
| @@ -70,7 +70,7 @@ | ||||
| </script> | ||||
|  | ||||
| <script type="text/x-red" data-help-name="trigger"> | ||||
|     <p>Sends a message if nothing is received within a set time interval or until reset.</p> | ||||
|     <p>When triggered, can send a message, and then optionally a second message, unless extended or reset.</p> | ||||
|  | ||||
|     <h3>Inputs</h3> | ||||
|     <dl class="message-properties"> | ||||
| @@ -95,6 +95,8 @@ | ||||
|     progress will be cleared and no message triggered.</p> | ||||
|     <p>The node can be configured to resend a message at a regular interval until it | ||||
|     is reset by a received message.</p> | ||||
|     <p>Optionally, the node can be configured to treat messages with <code>msg.topic</code> as if they | ||||
|     are separate streams.</p> | ||||
| </script> | ||||
|  | ||||
| <script type="text/javascript"> | ||||
|   | ||||
| @@ -75,7 +75,7 @@ | ||||
|     <dl> | ||||
|         <dt>Number of messages</dt> | ||||
|         <dd>groups messages into sequences of a given length. The <b>overlap</b> | ||||
|         option specifies how many messages and the end of one sequence should be | ||||
|         option specifies how many messages at the end of one sequence should be | ||||
|         repeated at the start of the next sequence.</dd> | ||||
|  | ||||
|         <dt>Time interval</dt> | ||||
|   | ||||
| @@ -95,7 +95,7 @@ module.exports = { | ||||
|     }, | ||||
|     get: function(req,res) { | ||||
|         if (req.params[0].indexOf("_examples_/") === 0) { | ||||
|             var m = /^_examples_\/([^\/]+)\/(.*)$/.exec(req.params[0]); | ||||
|             var m = /^_examples_\/(@.*?\/[^\/]+|[^\/]+)\/(.*)$/.exec(req.params[0]); | ||||
|             if (m) { | ||||
|                 var module = m[1]; | ||||
|                 var path = m[2]; | ||||
|   | ||||
| @@ -24,7 +24,7 @@ function getListenPath() { | ||||
|     var fn = 'node-red-git-askpass-'+seed+'-sock'; | ||||
|     var listenPath; | ||||
|     if (process.platform === 'win32') { | ||||
|         listenPath = '\\\\.\\pipe\\'+getListenPath; | ||||
|         listenPath = '\\\\.\\pipe\\'+fn; | ||||
|     } else { | ||||
|         listenPath = path.join(process.env['XDG_RUNTIME_DIR'] || os.tmpdir(), fn); | ||||
|     } | ||||
|   | ||||
| @@ -15,6 +15,9 @@ | ||||
|  **/ | ||||
|  | ||||
| var should = require("should"); | ||||
| var sinon = require("sinon"); | ||||
| var fs = require("fs"); | ||||
| var fspath = require('path'); | ||||
| var request = require('supertest'); | ||||
| var express = require('express'); | ||||
| var bodyParser = require('body-parser'); | ||||
| @@ -27,7 +30,7 @@ var auth = require("../../../../red/api/auth"); | ||||
|  | ||||
| describe("api/editor/library", function() { | ||||
|  | ||||
|     function initLibrary(_flows,_libraryEntries,_examples) { | ||||
|     function initLibrary(_flows,_libraryEntries,_examples,_exampleFlowPathFunction) { | ||||
|         var flows = _flows; | ||||
|         var libraryEntries = _libraryEntries; | ||||
|         library.init(app,{ | ||||
| @@ -88,7 +91,8 @@ describe("api/editor/library", function() { | ||||
|             nodes: { | ||||
|                 getNodeExampleFlows: function() { | ||||
|                     return _examples; | ||||
|                 } | ||||
|                 }, | ||||
|                 getNodeExampleFlowPath: _exampleFlowPathFunction | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
| @@ -100,6 +104,13 @@ describe("api/editor/library", function() { | ||||
|             app.get("/library/flows",library.getAll); | ||||
|             app.post(new RegExp("/library/flows\/(.*)"),library.post); | ||||
|             app.get(new RegExp("/library/flows\/(.*)"),library.get); | ||||
|             app.response.sendFile = function (path) { | ||||
|                 app.response.json.call(this, {sendFile: path}); | ||||
|             }; | ||||
|             sinon.stub(fs,"statSync",function() { return true; }); | ||||
|         }); | ||||
|         after(function() { | ||||
|             fs.statSync.restore(); | ||||
|         }); | ||||
|         it('returns empty result', function(done) { | ||||
|             initLibrary({},{flows:{}}); | ||||
| @@ -200,6 +211,42 @@ describe("api/editor/library", function() { | ||||
|                     done(); | ||||
|                 }); | ||||
|         }); | ||||
|  | ||||
|         it('can retrieve an example flow', function(done) { | ||||
|             var examples = {"d":{"node-module":{"f":["example-one"]}}}; | ||||
|             initLibrary({},{},examples,function(module,path) { | ||||
|                 return module + ':' + path | ||||
|             }); | ||||
|             request(app) | ||||
|                 .get('/library/flows/_examples_/node-module/example-one') | ||||
|                 .expect(200) | ||||
|                 .end(function(err,res) { | ||||
|                     if (err) { | ||||
|                         throw err; | ||||
|                     } | ||||
|                     res.body.should.have.property('sendFile', | ||||
|                         'node-module:example-one'); | ||||
|                     done(); | ||||
|                 }); | ||||
|         }); | ||||
|  | ||||
|         it('can retrieve an example flow in an org scoped package', function(done) { | ||||
|             var examples = {"d":{"@org_scope/node_package":{"f":["example-one"]}}}; | ||||
|             initLibrary({},{},examples,function(module,path) { | ||||
|                 return module + ':' + path | ||||
|             }); | ||||
|             request(app) | ||||
|                 .get('/library/flows/_examples_/@org_scope/node_package/example-one') | ||||
|                 .expect(200) | ||||
|                 .end(function(err,res) { | ||||
|                     if (err) { | ||||
|                         throw err; | ||||
|                     } | ||||
|                     res.body.should.have.property('sendFile', | ||||
|                         '@org_scope/node_package:example-one'); | ||||
|                     done(); | ||||
|                 }); | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     describe("type", function() { | ||||
|   | ||||
| @@ -29,7 +29,7 @@ function getListenPath() { | ||||
|     var fn = 'node-red-git-askpass-'+seed+'-sock'; | ||||
|     var listenPath; | ||||
|     if (process.platform === 'win32') { | ||||
|         listenPath = '\\\\.\\pipe\\'+getListenPath; | ||||
|         listenPath = '\\\\.\\pipe\\'+fn; | ||||
|     } else { | ||||
|         listenPath = path.join(process.env['XDG_RUNTIME_DIR'] || os.tmpdir(), fn); | ||||
|     } | ||||
| @@ -55,9 +55,10 @@ describe("localfilesystem/projects/git/authWriter", function() { | ||||
|         var listenPath = getListenPath(); | ||||
|  | ||||
|         server.listen(listenPath, function(ready) { | ||||
|             child_process.exec(process.execPath+' "'+authWriter+'" "'+listenPath+'" TEST_PHRASE_FOO',{cwd:__dirname}, (error,stdout,stderr) => { | ||||
|             child_process.exec('"'+process.execPath+'" "'+authWriter+'" "'+listenPath+'" TEST_PHRASE_FOO',{cwd:__dirname}, (error,stdout,stderr) => { | ||||
|                 server.close(); | ||||
|                 try { | ||||
|                     should.not.exist(error); | ||||
|                     receivedData.should.eql("TEST_PHRASE_FOO\n"); | ||||
|                     done(); | ||||
|                 } catch(err) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user