Support for LuaRocks (thanks albert!)

Fri, 23 Apr 2010 14:32:28 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 23 Apr 2010 14:32:28 +0100
changeset 2
1eabe33d7af7
parent 1
d9d0f9517ca0
child 3
fb9987d6df5d

Support for LuaRocks (thanks albert!)

xmpp-fingerprint.lua file | annotate | diff | comparison | revisions
--- a/xmpp-fingerprint.lua	Wed Apr 21 17:03:44 2010 +0100
+++ b/xmpp-fingerprint.lua	Fri Apr 23 14:32:28 2010 +0100
@@ -1,6 +1,14 @@
 #!/usr/bin/env lua
 
-local socket = require "socket";
+function softreq(...) local ok, lib =  pcall(require, ...); if ok then return lib; else 
+return nil, lib; end end
+
+-- Required to be able to find packages installed with luarocks
+if not softreq "luarocks.loader" then -- LuaRocks 2.x
+        softreq "luarocks.require"; -- LuaRocks <1.x
+end
+
+local socket = softreq "socket";
 
 -- Defaults --
 default_port = 5222;

mercurial