profiles api v2

This commit is contained in:
Emil Tin
2017-05-18 14:27:28 +02:00
committed by Patrick Niklaus
parent 5ece65cade
commit e413b25cd9
41 changed files with 1858 additions and 1208 deletions
+9 -6
View File
@@ -248,17 +248,20 @@ module.exports = function () {
fs.writeFile(this.penaltiesCacheFile, data, callback);
});
this.Given(/^the profile file(?: "([^"]*)" extended with)?$/, (profile, data, callback) => {
this.Given(/^the profile file(?: "([^"]*)" initialized with)?$/, (profile, data, callback) => {
const lua_profiles_path = this.PROFILES_PATH.split(path.sep).join('/');
let text = 'package.path = "' + lua_profiles_path + '/?.lua;" .. package.path\n';
if (profile == null) {
text += data + '\n';
} else {
text += 'local f = assert(io.open("' + lua_profiles_path + '/' + profile + '.lua", "r"))\n';
text += 'local s = f:read("*all") .. [[\n' + data + '\n]]\n';
text += 'f:close()\n';
text += 'local m = assert(loadstring and loadstring(s) or load(s))\n';
text += 'm()\n';
text += 'local functions = require("' + profile + '")\n';
text += 'functions.setup_parent = functions.setup\n';
text += 'functions.setup = function()\n';
text += 'local profile = functions.setup_parent()\n';
text += data + '\n';
text += 'return profile\n';
text += 'end\n';
text += 'return functions\n';
}
this.profileFile = this.profileCacheFile;
// TODO: Don't overwrite if it exists