Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
config.rulesDir = path.join(baseDir, 'rules');
config.valuesDir = path.join(baseDir, 'values');
config.propertiesDir = path.join(baseDir, 'properties');
if (config.storage && newConf.copy) {
var copyDir = typeof newConf.copy == 'string' && encodeURIComponent(newConf.copy);
if (copyDir !== config.storage) {
var dataDir = copyDir ? path.join(customDirs, copyDir) : config.baseDir;
var rulesDir = path.join(dataDir, 'rules');
var valuesDir = path.join(dataDir, 'values');
var propsDir = path.join(dataDir, 'properties');
fse.ensureDirSync(rulesDir);
fse.ensureDirSync(valuesDir);
fse.ensureDirSync(propsDir);
fse.copySync(rulesDir, config.rulesDir);
fse.copySync(valuesDir, config.valuesDir);
fse.copySync(propsDir, config.propertiesDir);
}
}
var clientIdFile = path.join(config.baseDir, '.clientid');
var clientId = readFileText(clientIdFile);
if (!clientId) {
clientId = [Date.now(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random()].join();
fs.writeFileSync(clientIdFile, clientId);
}
config.clientId = clientId;
config.LOCAL_FILES = path.join(config.baseDir, 'local_files');
fse.ensureDirSync(config.LOCAL_FILES);
config.setModified = function(clientId, isRules) {
if (isRules) {
config.mrulesClientId = clientId || '';
config.mrulesTime = Date.now();
} else {
config.passwordHash = createHash(config.password);
}
config.rulesDir = path.join(baseDir, 'rules');
config.valuesDir = path.join(baseDir, 'values');
config.propertiesDir = path.join(baseDir, 'properties');
if (config.storage && newConf.copy) {
var copyDir = typeof newConf.copy == 'string' && encodeURIComponent(newConf.copy);
if (copyDir !== config.storage) {
var dataDir = copyDir ? path.join(customDirs, copyDir) : config.baseDir;
var rulesDir = path.join(dataDir, 'rules');
var valuesDir = path.join(dataDir, 'values');
var propsDir = path.join(dataDir, 'properties');
fse.ensureDirSync(rulesDir);
fse.ensureDirSync(valuesDir);
fse.ensureDirSync(propsDir);
fse.copySync(rulesDir, config.rulesDir);
fse.copySync(valuesDir, config.valuesDir);
fse.copySync(propsDir, config.propertiesDir);
}
}
var clientIdFile = path.join(config.baseDir, '.clientid');
var clientId = readFileText(clientIdFile);
if (!clientId) {
clientId = [Date.now(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random()].join();
fs.writeFileSync(clientIdFile, clientId);
}
config.clientId = clientId;
config.LOCAL_FILES = path.join(config.baseDir, 'local_files');
fse.ensureDirSync(config.LOCAL_FILES);
config.setModified = function(clientId, isRules) {
if (isRules) {
config.mrulesClientId = clientId || '';
}).on('exit', function(code) {
if (code) {
removeDir(installPath);
} else {
var realPath = getInstallPath(name, result.dir);
removeDir(realPath);
try {
fs.renameSync(installPath, realPath);
} catch (e) {
fse.copySync(installPath, realPath);
try {
removeDir(installPath);
} catch (e) {}
}
}
});
}
}
config.rulesDir = path.join(baseDir, 'rules');
config.valuesDir = path.join(baseDir, 'values');
config.propertiesDir = path.join(baseDir, 'properties');
if (config.storage && newConf.copy) {
var copyDir = typeof newConf.copy == 'string' && encodeURIComponent(newConf.copy);
if (copyDir !== config.storage) {
var dataDir = copyDir ? path.join(customDirs, copyDir) : config.baseDir;
var rulesDir = path.join(dataDir, 'rules');
var valuesDir = path.join(dataDir, 'values');
var propsDir = path.join(dataDir, 'properties');
fse.ensureDirSync(rulesDir);
fse.ensureDirSync(valuesDir);
fse.ensureDirSync(propsDir);
fse.copySync(rulesDir, config.rulesDir);
fse.copySync(valuesDir, config.valuesDir);
fse.copySync(propsDir, config.propertiesDir);
}
}
var clientIdFile = path.join(config.baseDir, '.clientid');
var clientId = readFileText(clientIdFile);
if (!clientId) {
clientId = [Date.now(), Math.random(), Math.random(), Math.random(), Math.random(), Math.random()].join();
fs.writeFileSync(clientIdFile, clientId);
}
config.clientId = clientId;
config.LOCAL_FILES = path.join(config.baseDir, 'local_files');
fse.ensureDirSync(config.LOCAL_FILES);
config.setModified = function(clientId, isRules) {
if (isRules) {
config.mrulesClientId = clientId || '';
config.mrulesTime = Date.now();