The Wayback Machine - https://web.archive.org/web/20150923161532/https://www.npmjs.com/package/finepack

finepack

Organizes and maintains readable your JSON files

finepack

Image Image Image Image Image Image

Organizes and maintains readable your JSON files.

Image

Finepack is a tool to keep your JSON files organized, specially if you are creating an open source project and want to be sure that your files have all the information that is necessary for the mainly packet systems (like bower or npm). With it you you'll:

  • Lint the JSON to be sure that is in a valid format.
  • Validates the keys for be sure that exists the required keys as name or version and other important keys as homepage, main, license,...
  • Organizes a JSON putting the most important properties above.
  • Sorts the rest of the keys alphabetically and recursively.

You can use as CLI tool or from NodeJS as a library more. Based in fixpack but with a little more of ♥.

npm install finepack -g
$ finepack
 
  Organizes and maintains readable your JSON files
 
  Usage
    $ finepack <fileJSON> [options]
 
    options:
     --no-validate disable validation mode.
     --no-color    disable colors in the output.
     --version     output the current version.
 
    examples:
     finepack package.json
     finepack bower.json --no-validate

For uses inside your NodeJS project, just install as normal dependency.

var fs       = require('fs');
var path     = require('path');
var finepack = require('finepack');
var filepath = path.resolve('./package.json');
var filename = path.basename(filepath);
var filedata = fs.readFileSync(filepath, {encoding: 'utf8'});
 
var options = {
  filename: filename, // for customize the output messages, but is not necessary. 
  validate: false, // For enable (or not) keys validation (false by default). 
  color: false // For enable (or not) colorize or not the output (false by default). 
}
 
finepack(filedata, options, function(erroutputmessages){
  if (err){
    // if your JSON is malformed then you have err 
  }
});

MIT © Kiko Beats