How to use the js-beautify.beautify function in js-beautify

To help you get started, we’ve selected a few js-beautify 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 liuxx001 / bird-front / version.js View on Github external
const writeVersion = () => new Promise((resolve, reject) => {
  const { version } = config
  const numbers = version.split('.')
  numbers[2] = Number(numbers[2]) + 1
  config.version = numbers.join('.')

  fs.writeFile(path.join(__dirname, 'package.json'), beautify(JSON.stringify(config), { indent_size: 2 }), (err) => {
    if (err) {
      reject()
    }
    resolve()
    console.log(`version: ${config.version}`)
  })
})