Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
write(key, value) {
dotDrop.set(rawConfig, key, value)
writeConfig()
},
set(key, value) { // write with emit event
if (fs.existsSync(this.getProjectPath('.wordup','config.yml'))) {
try {
this.dotWordupYml = YAML.parseDocument(fs.readFileSync(this.getProjectPath('.wordup','config.yml'), 'utf8'))
this.dotWordupJson = this.dotWordupYml.toJSON()
} catch (err) {
this.error('Could not parse wordup config: '+err, {exit:1})
}
// Create the slug as a name. Because it could be also a path
const slug = this.wPkg('slug')
if(slug){
if (slug.lastIndexOf('/') !== -1) {
dotProp.set(this.dotWordupJson, 'slugName', slug.substring(0, slug.lastIndexOf('/')))
} else {
dotProp.set(this.dotWordupJson, 'slugName', slug)
}
}
// Get config based on the current path
this.config = this._wordupConfigstore.get('projects.' + this.projectId)
//Set docker-compose files
if (fs.existsSync(this.getProjectPath('docker-compose.yml'))) {
// If there is a local docker-compose.yml file, extend it
composerFiles += seperator + this.getProjectPath('docker-compose.yml')
}
}
//Set env which are the same for each project
shell.env.COMPOSE_FILE = composerFiles
let value = params[key];
if (key !== 'sku') {
if (/^\d+$/.test(value)) {
value = parseInt(value);
} else if (/^\d+(\.\d+)?$/.test(value)) {
value = parseFloat(value);
} else if (value === 'true') {
value = true;
} else if (value === 'false') {
value = false;
}
}
dotProp.set(parsed, key.trim(), value);
}
}
return parsed;
}
this.modifyJson(json => {
prop.set(json, `preset`, presetName);
});
}
const set = (key, value) => {
checkValueType(key, value);
if (this._options.accessPropertiesByDotNotation) {
dotProp.set(store, key, value);
} else {
store[key] = value;
}
};
set(key, val) {
if (typeof key !== 'string' && typeof key !== 'object')
throw new TypeError(`Expected \`key\` to be of type \`string\` or \`object\`, got ${typeof key}`)
const data = this.data
if (typeof key === 'object') {
for (const k of Object.keys(key)) {
DotProp.set(data, k, key[k])
}
} else {
DotProp.set(data, key, val)
}
this.data = data
}
has(key) {
Model.prototype.set = function (key, value) {
if (typeof key !== 'object' && typeof key !== 'string') {
throw new TypeError(`Expected \`key\` to be string or object, not ${typeof key}`);
}
const fields = {};
if (typeof key === 'object') {
Object.assign(fields, key);
} else {
dotProp.set(fields, key, value);
}
this.store.dispatch(set(fields));
};
_set(key, value) {
const {store} = this;
dotProp.set(store, key, value);
this.store = store;
}
this.modifyJson(json => {
prop.set(json, `fields.${id}.type`, type);
if (name) {
prop.set(json, `fields.${id}.name`, name);
}
if (description) {
prop.set(json, `fields.${id}.description`, description);
}
if (required) {
prop.set(json, `fields.${id}.required`, required);
}
if (defaultValue) {
prop.set(json, `fields.${id}.default`, defaultValue);
}
if (options) {
prop.set(json, `fields.${id}.options`, options);
}
});
}
this.modifyJson(json => {
prop.set(json, `fields.${id}.type`, type);
if (name) {
prop.set(json, `fields.${id}.name`, name);
}
if (description) {
prop.set(json, `fields.${id}.description`, description);
}
if (required) {
prop.set(json, `fields.${id}.required`, required);
}
if (defaultValue) {
prop.set(json, `fields.${id}.default`, defaultValue);
}
if (options) {
prop.set(json, `fields.${id}.options`, options);
}
});