Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Updating readme to latest in prep #12

Merged
merged 2 commits into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
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
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,23 @@
- [`dependency-check`][dependency-check] Makes sure you didn't forget to update
your `package.json` with new dependencies or remove dependencies your module
isn't using anymore.
- [`jsfmt`][jsfmt] Formats your code to the syleguide for you.
- [`eslint`][eslint] Makes sure your code conforms to the syleguide for cases
that aren't just simple formatting and are probably bugs.

## Example

First, install [pre-commit][pre-commit], which actually sets up the git precommit hook:
First, install [pre-commit][pre-commit], which actually sets up the git pre-commit hook:

```bash
npm install --save-dev pre-commit mongodb-js-precommit
npm install --save-dev mongodb-js-precommit
```

Next, update your `package.json` to add a new `check` script and condifure
[pre-commit][pre-commit] to run it:
Next, update your `package.json` to add a new `check` script:

```json
"scripts": {
"check": "mongodb-js-precommit"
},
"precommmit": ["check"]
}
```

To test that everything is working correctly, you can run:
Expand Down Expand Up @@ -58,7 +55,7 @@ new found free time that would have been spent on code reviews.

### precommit

Checkout the [pre-commit configuration docs][pre-commit_config] for more details.
This should just work no config required...

### eslint

Expand All @@ -68,7 +65,7 @@ For more information, checkout [eslint-config-mongodb-js][eslint-config-mongodb-

- [`npm-check-updates`][npm-check-updates] Can we safely update dependency
versions to latest safely?
- [`nsp`][nsp] Are you using any modules with known security vulnerabilites?
- `npm audit` Are you using any modules with known security vulnerabilites?

## License

Expand Down
36 changes: 18 additions & 18 deletions bin/mongodb-js-precommit.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,11 @@ if (args.version) {
process.exit(1);
}

function hr(inputHrStr) {
var width = (process.stdout.isTTY) ? process.stdout.getWindowSize()[0] : 0;
var hrStr = inputHrStr.length > 0 ? inputHrStr : '=';
var out = (Array(Math.floor(width / hrStr.length) + 1).join(hrStr));

var partialLen = (width - (Math.floor(width / hrStr.length)) * hrStr.length);
out += hrStr.substring(0, partialLen);
console.log(chalk.gray(out));
}

console.log(
chalk.gray('Checking for potential errors' + figures.ellipsis)
);

precommit(args, function(err, res) {
if (!args.json) {
hr(figures.line);
}

if (err) {
if (args.json) {
err = JSON.stringify(err, null, 2);
Expand All @@ -76,14 +65,25 @@ precommit(args, function(err, res) {
if (args.json) {
console.log(JSON.stringify(res, null, 2));
} else {
console.log(chalk.green(' ', figures.tick), ' OK! 0 potential errors found');
console.log(
chalk.green(' ', figures.tick),
' 0 potential errors found'
);

if (res.result.warnings.length > 0) {
console.log('\n', chalk.yellow(' ', figures.warning),
' ' + res.result.warnings.length + ' check(s) produced warnings you should be aware of:\n');
console.log(
'\n',
chalk.yellow(' ', figures.warning),
' ' +
res.result.warnings.length +
' check(s) produced warnings you should be aware of:\n'
);

res.result.warnings.map(function(warning) {
console.log(' ' + chalk.yellow.bold(' ', figures.warning), ' ' + warning.title + '\n');
console.log(
' ' + chalk.yellow.bold(' ', figures.warning),
' ' + warning.title + '\n'
);
warning.message.split('\n').forEach(function(line) {
console.log(' ' + line);
});
Expand Down
11 changes: 0 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ function check(options, mode, done) {
opts.ignore.push.apply(opts.ignore, [
'eslint-config-mongodb-js',
'mongodb-js-precommit',
'mongodb-js-fmt',
'pre-commit'
]);

Expand Down Expand Up @@ -278,16 +277,6 @@ module.exports = function(opts, done) {
opts.globs = [opts.globs];
}

console.log(chalk.gray(
'Checking for potential errors' + figures.ellipsis));
console.log(chalk.gray('Use the'),
chalk.gray.bold('--debug'),
chalk.gray('flag to print diagnostic info')
);

console.log(chalk.gray('For more info, please see'),
chalk.gray.bold('https://github.com/mongodb-js/precommit'), '\n');

var checks = [
check.bind(null, opts, 'missing'),
check.bind(null, opts, 'extra'),
Expand Down