-
Notifications
You must be signed in to change notification settings - Fork 7
/
Gruntfile.js
70 lines (64 loc) · 2.06 KB
/
Gruntfile.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
'use strict';
module.exports = function ( grunt ) {
const conf = grunt.file.readJSON( 'extension.json' );
grunt.loadNpmTasks( 'grunt-banana-checker' );
grunt.loadNpmTasks( 'grunt-contrib-watch' );
grunt.loadNpmTasks( 'grunt-eslint' );
grunt.loadNpmTasks( 'grunt-stylelint' );
grunt.initConfig( {
eslint: {
options: {
cache: true,
fix: grunt.option( 'fix' )
},
all: '.'
},
banana: conf.MessagesDirs,
watch: {
files: [
'.{stylelintrc}.json',
'<%= eslint.alll %>'
],
tasks: 'test'
},
stylelint: {
all: [
'**/*.{css,less}',
'!node_modules/**',
'!lib/**',
'!docs/**',
'!vendor/**'
]
}
} );
grunt.registerTask( 'libcheck', function () {
const done = this.async();
// Are there unstaged changes after synchronizing from upstream libraries?
require( 'child_process' ).exec( 'git ls-files lib/external --modified', ( err, stdout, stderr ) => {
// Before we try to rebuild lib/external files, let's make sure there aren't any local
// unstaged changes first in those files, so we don't override uncommitted work
const ret = err || stderr || stdout;
if ( ret ) {
grunt.log.error( 'There are uncommitted changes to external library files. Please change these files upstream, instead.' );
grunt.log.error( ret );
} else {
// Build the lib files and verify there isn't a difference
require( 'child_process' ).exec( 'npm run build-lib', () => {
require( 'child_process' ).exec( 'git ls-files lib/external --modified', ( err2, stdout2, stderr2 ) => {
const ret2 = err2 || stderr2 || stdout2;
if ( ret2 ) {
grunt.log.error( 'These library files were directly changed. Please change them upstream, instead:' );
grunt.log.error( ret2 );
} else {
grunt.log.ok( 'Library folder is synchronized with upstream libraries\' states.' );
done();
}
} );
} );
}
} );
} );
grunt.registerTask( 'lint', [ 'eslint', 'stylelint', 'banana' ] );
grunt.registerTask( 'test', [ 'lint', 'libcheck' ] );
grunt.registerTask( 'default', 'test' );
};