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 |
|
24 |
|
25 | var Stylint = function( path, config, callback ) {
|
26 | return stampit().compose(
|
27 | require( './src/core/' ),
|
28 | require( './src/checks/' ),
|
29 | require( './src/state/' ),
|
30 | stampit().enclose( function() {
|
31 | var pkg = require( process.cwd() + '/package.json' )
|
32 |
|
33 |
|
34 | if ( typeof path === 'undefined' ) {
|
35 | this.state.path = './'
|
36 | }
|
37 | else if ( path instanceof Array || typeof path === 'string' ) {
|
38 | this.state.path = path
|
39 | }
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 | if ( typeof pkg.stylintignore !== 'undefined' &&
|
46 | pkg.stylintignore instanceof Array ) {
|
47 | this.state.exclude = pkg.stylintignore
|
48 | }
|
49 | else {
|
50 | try {
|
51 | var stylintIgnore = fs.readFileSync( process.cwd() + '/.stylintignore' )
|
52 | this.state.exclude = stylintIgnore
|
53 | .toString()
|
54 | .split( '\n' )
|
55 | .filter( function( d ) {
|
56 | return d
|
57 | } )
|
58 | }
|
59 | catch ( err ) {
|
60 |
|
61 | }
|
62 | }
|
63 |
|
64 | this.customConfig = typeof config === 'object' ? config : false
|
65 | this.callback = callback || function() {}
|
66 | } ).enclose( require( './src/core/init' ) )
|
67 | )
|
68 | }
|
69 |
|
70 | module.exports = Stylint
|