Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function tryPhantomjsInLib() {
return kew.fcall(function () {
return findValidPhantomJsBinary(path.resolve(__dirname, './lib/location.js'))
}).then(function (binaryLocation) {
if (binaryLocation) {
console.log('PhantomJS is previously installed at', binaryLocation)
exit(0)
}
}).fail(function () {
// silently swallow any errors
})
}
function tryPhantomjsInLib() {
return kew.fcall(function () {
return findValidPhantomJsBinary(path.resolve(__dirname, './lib/location.js'))
}).then(function (binaryLocation) {
if (binaryLocation) {
console.log('PhantomJS is previously installed at', binaryLocation)
exit(0)
}
}).fail(function () {
// silently swallow any errors
})
}
ControllerMpd.prototype.parsePlaylist = function(objQueue) {
var self = this;
self.commandRouter.pushConsoleMessage('[' + Date.now() + '] ' + 'ControllerMpd::parsePlaylist');
// objQueue is in form {'0': 'file: http://uk4.internet-radio.com:15938/', '1': 'file: http://2363.live.streamtheworld.com:80/KUSCMP128_SC'}
// We want to convert to a straight array of trackIds
return libQ.fcall(libFast.map, Object.keys(objQueue), function(currentKey) {
return convertUriToTrackId(objQueue[currentKey]);
});
};
var compile_template = function (filename) {
return Q
.fcall(function () {
// return cached immediately
if (cache[filename]) {
return cache[filename]
}
// (asynchronously) load and compile template
$.util.log('loading template: ' + filename)
return Q
.nfcall(fs.readFile, filename)
.then(function (tmpl_content) {
// turn template in promise returning function and cache it
var compiled = jade.compile(tmpl_content, {pretty: true, filename: filename})
$.util.log('compiled template: ' + chalk.yellow(filename))
return (cache[filename] = compiled)
})
InterfaceWebUI.prototype.pushLibraryListing = function(browsedata, connWebSocket) {
var self = this;
self.commandRouter.pushConsoleMessage('[' + Date.now() + '] ' + 'InterfaceWebUI::pushLibraryListing');
// If a specific client is given, push to just that client
if (connWebSocket) {
return libQ.fcall(libFast.bind(connWebSocket.emit, connWebSocket), 'pushLibraryListing', browsedata);
}
}
InterfaceWebUI.prototype.pushState = function(state, connWebSocket) {
var self = this;
self.commandRouter.pushConsoleMessage('[' + Date.now() + '] ' + 'InterfaceWebUI::pushState');
if (connWebSocket) {
self.pushMultiroom(connWebSocket);
return libQ.fcall(libFast.bind(connWebSocket.emit, connWebSocket), 'pushState', state);
} else {
// Push the updated state to all clients
self.pushMultiroom(self.libSocketIO);
return libQ.fcall(libFast.bind(self.libSocketIO.emit, self.libSocketIO), 'pushState', state);
}
}
ControllerMpd.prototype.parsePlaylist = function (objQueue) {
var self = this;
self.commandRouter.pushConsoleMessage('ControllerMpd::parsePlaylist');
// objQueue is in form {'0': 'file: http://uk4.internet-radio.com:15938/', '1': 'file: http://2363.live.streamtheworld.com:80/KUSCMP128_SC'}
// We want to convert to a straight array of trackIds
return libQ.fcall(libFast.map, Object.keys(objQueue), function (currentKey) {
return convertUriToTrackId(objQueue[currentKey]);
});
};
InterfaceWebUI.prototype.pushState = function (state, connWebSocket) {
var self = this;
self.commandRouter.pushConsoleMessage('[' + Date.now() + '] ' + 'InterfaceWebUI::pushState');
if (connWebSocket) {
self.pushMultiroom(connWebSocket);
return libQ.fcall(connWebSocket.emit.bind(connWebSocket), 'pushState', state);
} else {
// Push the updated state to all clients
self.pushMultiroom(self.libSocketIO);
return libQ.fcall(self.libSocketIO.emit.bind(self.libSocketIO), 'pushState', state);
}
};
builder.add(function testBatchGetBadKey(test) {
var client = this.client
return Q.fcall(
function () {
return client.newBatchGetBuilder()
.setPrefix('pre_')
.requestItems('many', manyData.map(function () { return {'hashKey': {}, 'column': '@'}}))
.execute()
})
.then(function () {
test.fail('Expected error')
})
.fail(function (err) {
if (err.message != 'Invalid dynamo value. Type: object, Value: [object Object]') throw err
})
})
function findValidPhantomJsBinary(libPath) {
return kew.fcall(function () {
var libModule = require(libPath)
if (libModule.location &&
getTargetPlatform() == libModule.platform &&
getTargetArch() == libModule.arch) {
var resolvedLocation = path.resolve(path.dirname(libPath), libModule.location)
if (fs.statSync(resolvedLocation)) {
return checkPhantomjsVersion(resolvedLocation).then(function (matches) {
if (matches) {
return kew.resolve(resolvedLocation)
}
})
}
}
return false
}).fail(function () {
return false