1 | 'use strict'
|
2 |
|
3 |
|
4 | var stampit = require( 'stampit' )
|
5 | var fs = require( 'fs' )
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | var Stylint = function( path, config, callback ) {
|
24 | return stampit().compose(
|
25 | require( './src/core/' ),
|
26 | require( './src/checks/' ),
|
27 | require( './src/state/' ),
|
28 | stampit().enclose( function() {
|
29 | var pkg = require( process.cwd() + '/package.json' )
|
30 |
|
31 |
|
32 | if ( typeof path === 'undefined' ) {
|
33 | this.state.path = './'
|
34 | }
|
35 | else if ( path instanceof Array || typeof path === 'string' ) {
|
36 | this.state.path = path
|
37 | }
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | if ( typeof pkg.stylintignore !== 'undefined' &&
|
44 | pkg.stylintignore instanceof Array ) {
|
45 | this.state.exclude = pkg.stylintignore
|
46 | }
|
47 | else {
|
48 | try {
|
49 | var stylintIgnore = fs.readFileSync( process.cwd() + '/.stylintignore' )
|
50 | this.state.exclude = stylintIgnore
|
51 | .toString()
|
52 | .split( '\n' )
|
53 | .filter( function( d ) {
|
54 | return d
|
55 | } )
|
56 | }
|
57 | catch ( err ) {
|
58 |
|
59 | }
|
60 | }
|
61 |
|
62 | this.customConfig = typeof config === 'object' ? config : false
|
63 | this.callback = callback || function() {}
|
64 | } ).enclose( require( './src/core/init' ) )
|
65 | )
|
66 | }
|
67 |
|
68 | module.exports = Stylint
|