Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return arena[method](slug).get().then(item => {
let content = {}, before = {};
if (argv.yaml) {
before = pick(item, editable);
content = yaml.safeLoad(editor.edit(yaml.safeDump(before,
{ lineWidth: 78 })));
} else {
before[editable[0]] = item[editable[0]];
content[editable[0]] = editor.edit(before[editable[0]])
.replace(/[\r\n]+$/, '');
}
if (!isEqual(content, before)) {
// Use Object.assign: currently a bug in are.na's API prevents
// updating partially without wiping out the other fields (i.e.:
// passing only "content" to be updated will wipe out title and
// description if they are not set)
return arena[method](item.id)
.update(Object.assign({}, pick(item, editable), content))
.then(result => {
// Returns new object for channels, not blocks
return Promise.resolve((result ? result.id : slug) + ': OK.');
});
} else {
return Promise.resolve(slug + ': No change, not updated.');
}
return arena[method](slug).get().then(item => {
let content = {}, before = {};
if (argv.yaml) {
before = pick(item, editable);
content = yaml.safeLoad(editor.edit(yaml.safeDump(before,
{ lineWidth: 78 })));
} else {
before[editable[0]] = item[editable[0]];
content[editable[0]] = editor.edit(before[editable[0]])
.replace(/[\r\n]+$/, '');
}
if (!isEqual(content, before)) {
// Use Object.assign: currently a bug in are.na's API prevents
// updating partially without wiping out the other fields (i.e.:
// passing only "content" to be updated will wipe out title and
// description if they are not set)
return arena[method](item.id)
.update(Object.assign({}, pick(item, editable), content))
.then(result => {
// Returns new object for channels, not blocks
return Promise.resolve((result ? result.id : slug) + ': OK.');