diff --git a/package.json b/package.json index 2af6870..511bb4a 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,5 @@ "grunt-contrib-nodeunit": "~0.2.2", "grunt-contrib-jshint": "~0.7.2", "express": "~3.4.8" - }, - "dependencies": { - "underscore": "~1.6.0", - "socket.io-client": "~0.9.16" } } diff --git a/src/client/cloak.js b/src/client/cloak.js index b30c342..de60213 100644 --- a/src/client/cloak.js +++ b/src/client/cloak.js @@ -1,19 +1,7 @@ /* cloak client */ -/* global module,console */ - -(function(global, factory) { - - if (typeof global.define === 'function' && global.define.amd) { - define(['underscore', 'socket.io-client'], factory); - } else if (typeof module === 'object' && module.exports) { - module.exports = factory( - require('underscore'), require('socket.io-client') - ); - } else { - global.cloak = factory(global._, global.io); - } +/* global cloak:true,module,io:true,console,_:true */ -})(this, function(_, io) { +(function() { var removeKey = function(val, key, obj) { delete obj[key]; @@ -30,6 +18,17 @@ var cloak = { + _setLibs: function(a, b) { + _ = a; + io = b; + }, + + /** + * Set configuration options for Cloak. These options will be applied + * immediately if Cloak has already been started (see `cloak.run`), and + * they will be referenced in all future calls to `clock.run` until + * overwritten. + */ configure: function(configArg) { // When specified, the `messages` option should trigger the complete @@ -227,5 +226,11 @@ }; - return createCloak(); -}); + if (typeof window === 'undefined') { + module.exports = createCloak; + } + else { + cloak = createCloak(); + } + +}()); diff --git a/test/lib/superSuite.js b/test/lib/superSuite.js index 284e5dd..27e8ffd 100644 --- a/test/lib/superSuite.js +++ b/test/lib/superSuite.js @@ -59,12 +59,9 @@ module.exports = { // function instead of doing it manually means clients // will be properly cleaned up after tests are done. createClient: function() { - var client; - - delete require.cache[require.resolve('../../src/client/cloak')]; - client = require('../../src/client/cloak'); + var client = createCloakClient(); + client._setLibs(_, io); clients.push(client); - return client; }