rokucommunity / brightscript-formatter

This project is no longer maintained. Its successor is brighterscript-formatter
https://github.com/RokuCommunity/brighterscript-formatter
Apache License 2.0
5 stars 5 forks source link

indentSpaceCount #1

Closed crwecker closed 6 years ago

crwecker commented 6 years ago

Awesome tool!!! I am so glad that you spent the time to put this together. Thank you so much! I'm new to js/ts/node etc, so I might just be doing something wrong, but setting the indentSpaceCount doesn't seem to change anything (it always just uses four spaces). Here is the code I put together (any feedback is welcome).

var {BrightScriptFormatter} = require('brightscript-formatter');
var fs = require('fs');

// print process.argv
inputFile = process.argv[2];

function readWrite() {
  fs.readFile(inputFile, 'utf8', function(err, data) {
    if (err) throw err;
    var bsf = new BrightScriptFormatter();
    var options = {
      indentStyle: 'spaces',
      indentSpaceCount: 2,
      keywordCase: 'lower',
      compositeKeywords: 'split'
    };
    newValue = bsf.format(data, options);
    fs.writeFile(inputFile, newValue, 'utf8', function (err) {
      if (err) throw err;
    });
  });
}

readWrite();
TwitchBronBron commented 6 years ago

Oops, good catch! I guess I forgot to implement that.

I just fixed the issue and published a new version to npm (v1.1.0). Give it a try and let me know how it goes.

crwecker commented 6 years ago

Works great. Awesome. Thanks!