-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
pretty-quick.js
executable file
·51 lines (42 loc) · 1.15 KB
/
pretty-quick.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env node
'use strict';
const chalk = require('chalk');
const mri = require('mri');
const prettyQuick = require('..').default;
const args = mri(process.argv.slice(2));
let success = true;
prettyQuick(
process.cwd(),
Object.assign({}, args, {
onFoundSinceRevision: (scm, revision) => {
console.log(
`🔍 Finding changed files since ${chalk.bold(
scm
)} revision ${chalk.bold(revision)}.`
);
},
onFoundChangedFiles: changedFiles => {
console.log(
`🎯 Found ${chalk.bold(changedFiles.length)} changed ${
changedFiles.length === 1 ? 'file' : 'files'
}.`
);
},
onPartiallyStagedFile: file => {
console.log(`✗ Found ${chalk.bold('partially')} staged file ${file}.`);
success = false;
},
onWriteFile: file => {
console.log(`✍️ Fixing up ${chalk.bold(file)}.`);
},
})
);
if (success) {
console.log('✅ Everything is awesome!');
} else {
console.log(
'✗ Partially staged files were fixed up.' +
` ${chalk.bold('Please update stage before committing')}.`
);
process.exit(1); // ensure git hooks abort
}