Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ Node-Beautify is a node.js module that can be easily required and used to beauti

## Installation

npm install node-beautify
```sh
npm install node-beautify
```

## Usage

to beautify javascript:

require('node-beautify').beautifyJs(source, options);

```javascript
require('node-beautify').beautifyJs(source, options);
```

where
source is a string of javascript source code and options (optional) allows overriding the defaults (see below)

Expand All @@ -27,31 +31,41 @@ where


## Example
// require the module
var nb = require('node-beautify');
```javascript
// require the module
var nb = require('node-beautify');

// pass a string of ugly javascript to the beautifyJs method
var prettyJs = nb.beautifyJs("function test(){console.log('test');}");
// pass a string of ugly javascript to the beautifyJs method
var prettyJs = nb.beautifyJs("function test(){console.log('test');}");

// the results should be a nicely formatted javascript string
console.log(prettyJs);
// the results should be a nicely formatted javascript string
console.log(prettyJs);
```

## To run tests
Mocha should be installed globally. If it is not, you can install it by typing

npm install mocha -g
```sh
npm install mocha -g
```

Clone the repository using git, e.g.

git clone https://github.com/fshost/node-beautify
```sh
git clone https://github.com/fshost/node-beautify
```

After the repo has been cloned, in the repo directory type

npm install
```sh
npm install
```

After all dependencies are installed, the tests can be run by typing

mocha
```sh
mocha
```

## Requirements

Expand Down