Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fs.readFile(fullPath, 'utf8', function (err, solutions) {
if (err) {
fluid.fail("FUCK OFF");
}
solutions = JSON.parse(solutions);
solutions = matchMaker.prefilterSolutions(solutions, device);
event.fire(solutions, rptmp);
});
// var fs = require('fs');
gpii.settingsDir.createGpii = function (that) {
fluid.log(fluid.logLevel.WARN, "Creating GPII settings directory in ", that.gpiiSettingsDir);
try { // See code skeleton in http://stackoverflow.com/questions/13696148/node-js-create-folder-or-use-existing
fs.mkdirSync(that.gpiiSettingsDir);
} catch (e) {
if (e.code !== "EEXIST") {
fluid.fail("Unable to create GPII settings directory, code is " + e.code + ": exception ", e);
}
}
};
gpii.userListeners.pcsc.detectCard = function (atr) {
if (!atr instanceof Buffer) {
fluid.fail("atr needs to be a Buffer.");
}
var knownCards = gpii.userListeners.pcsc.knownCards;
var card = fluid.find(knownCards, function (card) {
return fluid.find(card.atrs, function (atrTest) {
return atrTest.equals(atr) ? card : undefined;
});
});
return card || null;
};
promise.then(function (deviceData) {
if (deviceData.isError) {
fluid.fail("Error in device reporter data", deviceData.message);
}
event.fire(deviceData);
}, function (err) {
fluid.fail("Rejected device reporter promise: " + err.message);
gpii.flowManager.solutionsRegistry.dataSource.loadSolutionsRegistry = function (that) {
if (!that.options.path) {
fluid.fail("The solutionsRegistry datasource ", that, " needs a \"path\" option pointing to the solution entries folder");
}
var url = fluid.module.resolvePath(that.options.path);
if (!fs.existsSync(url)) {
fluid.fail("The path provided to the solutionsRegistry datasource (", url, ") has not been found on the file system");
}
that.fullSolutionsRegistry = fluid.freezeRecursive(require(url));
};
gpii.flowManager.solutionsRegistry.dataSource.loadSolutionsRegistry = function (that) {
if (!that.options.path) {
fluid.fail("The solutionsRegistry datasource ", that, " needs a \"path\" option pointing to the solution entries folder");
}
var url = fluid.module.resolvePath(that.options.path);
if (!fs.existsSync(url)) {
fluid.fail("The path provided to the solutionsRegistry datasource (", url, ") has not been found on the file system");
}
that.fullSolutionsRegistry = fluid.freezeRecursive(require(url));
};
gpii.settingsHandlers.exploding.explode = function (operation, explodeSettings) {
var errorMessage = "Exploding settings handler has failed on " + operation + " method";
var errorPayload = explodeSettings.errorPayload || {
isError: true,
message: errorMessage
};
if (explodeSettings.explodeMethod === "reject") {
return fluid.promise().reject(errorPayload);
} else if (explodeSettings.explodeMethod === "fail") {
fluid.fail(errorMessage);
} else if (explodeSettings.explodeMethod === "throw") {
throw new Error(errorMessage);
}
};
}, function (err) {
fluid.fail("Rejected device reporter promise: " + err.message);
});
};
settingPromise.then(null, function (reason) {
fluid.fail("remoteFileSettingsHandler failed for setting '" + key + "' in payload ", payload, reason);
});
gpii.journal.restoreJournal = function (journalThat, lifecycleManager, journalId) {
var parsed = gpii.journal.parseId(journalId);
if (parsed.isError) {
fluid.fail(parsed.message);
} else {
fluid.log("Restoring journal with id " + journalId);
var journal = gpii.journal.fetchJournal(journalThat.journalFiles, parsed);
if (!journal) {
return fluid.promise().reject({
isError: true,
message: "journal Id " + journalId + " could not be looked up to a journal"
});
} else {
fluid.log("Restoring journal snapshot with contents " + JSON.stringify(journal, null, 2));
return lifecycleManager.restoreSnapshot(journal.originalSettings);
}
}
};