How to use the external-editor.edit function in external-editor

To help you get started, we’ve selected a few external-editor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ivangreene / arena-cli / index.js View on Github external
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.');
          }
github ivangreene / arena-cli / index.js View on Github external
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.');

external-editor

Edit a string with the users preferred text editor using $VISUAL or $ENVIRONMENT

MIT
Latest version published 5 years ago

Package Health Score

65 / 100
Full package analysis

Popular external-editor functions