Merge pull request #4949 from AGhorab-upland/master

Add qoutes when installing local tgz to fix spacing in the file path
pull/4990/head
Nick O'Leary 2024-12-16 09:44:28 +00:00 committed by GitHub
commit 03507c2a1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View File

@ -144,7 +144,7 @@ async function installModule(module,version,url) {
if (url) { if (url) {
if (pkgurlRe.test(url) || localtgzRe.test(url)) { if (pkgurlRe.test(url) || localtgzRe.test(url)) {
// Git remote url or Tarball url - check the valid package url // Git remote url or Tarball url - check the valid package url
installName = url; installName = localtgzRe.test(url) && slashRe.test(url) ? `"${url}"` : url;
isRegistryPackage = false; isRegistryPackage = false;
} else { } else {
log.warn(log._("server.install.install-failed-url",{name:module,url:url})); log.warn(log._("server.install.install-failed-url",{name:module,url:url}));

View File

@ -258,6 +258,29 @@ describe('nodes/registry/installer', function() {
}).catch(done); }).catch(done);
}); });
it("succeeds when file path is valid node-red module", function(done) {
var nodeInfo = {nodes:{module:"foo",types:["a"]}};
var res = {
code: 0,
stdout:"",
stderr:""
}
var p = Promise.resolve(res);
p.catch((err)=>{});
execResponse = p;
var addModule = sinon.stub(registry,"addModule").callsFake(function(md) {
return Promise.resolve(nodeInfo);
});
installer.installModule("foo",null,"/example path/foo-0.1.1.tgz").then(function(info) {
exec.run.lastCall.args[1].should.eql([ 'install', '--no-audit', '--no-update-notifier', '--no-fund', '--save', '--save-prefix=~', '--omit=dev', '--engine-strict', '"/example path/foo-0.1.1.tgz"' ]);
info.should.eql(nodeInfo);
done();
}).catch(done);
});
it("triggers preInstall and postInstall hooks", function(done) { it("triggers preInstall and postInstall hooks", function(done) {
let receivedPreEvent,receivedPostEvent; let receivedPreEvent,receivedPostEvent;
hooks.add("preInstall", function(event) { event.args = ["a"]; receivedPreEvent = event; }) hooks.add("preInstall", function(event) { event.args = ["a"]; receivedPreEvent = event; })