Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)));
}
// Parse comment header
var flat = {};
var commentLines = stdout.match(/^#(.*)$/img);
if (commentLines && commentLines.length) {
commentLines.forEach(function(line) {
var cfgKey = line.match(/^#\s*([^:]+)\s*/)[1];
var cfgVal = line.match(/:\s*(.*)\s*$/)[1];
flat[cfgKey] = cfgVal;
});
}
// Convert flat -> structure to recursive
var nested = unflatten(flat, {
delimiter: '->',
object : true,
});
// Apply defaults to said config
_.extend(self, self.defaultConfig, nested.config);
// Fixed plugin options
self.name = path.basename(self.pluginFile, '.sh');
self.executable = !!(1 & parseInt ((fs.statSync(self.pluginFile).mode & parseInt('777', 8)).toString(8)[0]));
if (self.enabled === 'false') {
self.enabled = false;
} else {
self.enabled = true;
}
const rows = fp.map(p => flatten.unflatten(fp.fromPairs(fp.zip(fields, p))), xproduct(fp.map(v => (isChoice(v) ? nodeValue(v) : [v]), fp.values(compiledData))));
// filter rows (remove empty and nonvalid)
// Feed empty translation (null or "")
returnTranslations[k] = self.params.nullEmpty ? null : "";
}
});
}
if (!_.isUndefined(useDefault) && useDefault) {
returnTranslations = this.getDefaultTranslations(returnTranslations);
}
this.computeStats(obj, translations, returnTranslations);
// Case namespace (tree representation)
if (this.params.tree) {
// We need to remove parent NS
returnTranslations = flat.unflatten(Translations.cleanParents(returnTranslations));
}
return returnTranslations;
};
api.onAction('edit-message-action', ({ path, value, locale }) => {
debug('edit-message-action onAction', path, value, locale)
if (!currentProject || !currentConfig || !path) {
console.error('edit-message-action: invalid pre-condition !!')
return
}
const localePath = `${currentProject.path}/src/${currentConfig.localeDir}`
const locales = getLocales(localePath)
const localeMessages = getLocaleMessages(localePath, locales)
const orderData = getSharedData('order')
const messages = localeMessages[locale]
const flattendMessage = flatten(messages)
flattendMessage[path] = value
localeMessages[locale] = unflatten(flattendMessage)
writeLocaleMessages(localePath, locale, localeMessages[locale], orderData.value)
setSharedData('localeMessages', localeMessages)
setSharedData('localePaths', getLocalePaths(localeMessages))
})
const unflatten = data => flat.unflatten(data, { delimiter: "/", safe: true });
redis.hmset(`scenario:${intentId}`, flatScenario, (err) => {
if (err){
const error = Boom.badImplementation('An error occurred adding the scenario data.');
return cb(error);
}
return cb(null, Flat.unflatten(flatScenario));
});
});
const normalizeParams = (params: RecordJSON['params']): RecordJSON['params'] => (
flatten(unflatten(params, { overwrite: true }))
)
}, function(err, object) {
if (err) return callback(err)
object = flat.unflatten(object, { delimiter: path.sep })
callback(null, clean(reformat(object, 'name')))
})
}
var flatEnvValues = Object.keys(flattendDefaultConfig)
.reduce((envVarMap, key) => {
var envKey = prefix + delimiter + key.toUpperCase();
var value = process.env[envKey];
if (value !== undefined) {
envVarMap[key] = typeof flattendDefaultConfig[key] === 'number' ?
parseInt(value, 10) : value;
}
return envVarMap;
}, {});
const envConfig = flat.unflatten(flatEnvValues, flatConfig);
this.apply(envConfig);
}
redis.hmset(`entity:${entityId}`, RemoveBlankArray(flatEntity), (err) => {
if (err){
const error = Boom.badImplementation('An error occurred adding the entity data.');
return cb(error);
}
return cb(null, Flat.unflatten(flatEntity));
});
});