Beautify your code… with code!

Beautify your code… with code!

Automatization is an important area of software development. As developers, we should always look for ways to be more productive and do more with less.

These days, here at Regos, we are investing some time in code generation and tasks automatization. Thanks to those tasks we found this nice npm package:

The basic idea is to generate the code however you want and just format the generated files with this package. Here is an example of the basic usage.

const beautify = require('js-beautify').js;
const fs = require('fs');
fs.readFile('foo.js', 'utf8', function (err, data) {
    if (err) {
        throw err;
    console.log(beautify(data, { indent_size: 2, space_in_empty_paren: true }));

To be honest, the result is great and comes with a set of options for customization. The next time you work on code generation, we think is a good idea to give a chance to this package.

. . .

Regos Dev Studio is a product development company that builds add-ons for Jira and Confluence, combined with the development of custom solutions in a variety of languages.

Don’t forget to check out our website, visit our Atlassian marketplace listing. You can also follow us on Twitter or LinkedIn and stay tuned for updates!

Leave a Reply

Your email address will not be published. Required fields are marked *