8
8
* Licensed under the MIT license.
9
9
*/
10
10
11
- const request = require ( 'request' ) ,
12
- exec = require ( 'child_process' ) . exec ,
13
- spawn = require ( 'child_process' ) . spawn ,
14
- inquirer = require ( 'inquirer' ) ,
15
- url = require ( 'url' ) ,
16
- fs = require ( 'fs' ) ,
17
- _ = require ( 'underscore' ) ,
18
- trac = require ( '../lib/trac.js' ) ,
19
- patch = require ( '../lib/patch.js' ) ,
20
- regex = require ( '../lib/regex.js' ) ,
21
- xmlrpc = require ( 'xmlrpc' ) ,
22
- mapOldToNewFilePath = require ( '../lib/map_old_to_new_file_path.js' ) ;
11
+ const request = require ( 'request' ) ;
12
+ const exec = require ( 'child_process' ) . exec ;
13
+ const spawn = require ( 'child_process' ) . spawn ;
14
+ const inquirer = require ( 'inquirer' ) ;
15
+ const url = require ( 'url' ) ;
16
+ const fs = require ( 'fs' ) ;
17
+ const _ = require ( 'underscore' ) ;
18
+ const trac = require ( '../lib/trac.js' ) ;
19
+ const patch = require ( '../lib/patch.js' ) ;
20
+ const regex = require ( '../lib/regex.js' ) ;
21
+ const xmlrpc = require ( 'xmlrpc' ) ;
22
+ const mapOldToNewFilePath = require ( '../lib/map_old_to_new_file_path.js' ) ;
23
23
24
24
_ . str = _ . str = require ( 'underscore.string' ) ;
25
25
_ . mixin ( _ . str . exports ( ) ) ;
26
26
27
27
module . exports = function ( grunt ) {
28
- let tempFile = 'wppatch.diff' ,
29
- defaults = {
30
- tracUrl : 'core.trac.wordpress.org' ,
31
- } ;
28
+ let tempFile = 'wppatch.diff' ;
29
+ const defaults = {
30
+ tracUrl : 'core.trac.wordpress.org' ,
31
+ } ;
32
32
33
33
function isSvn ( ) {
34
34
return fs . existsSync ( '.svn' ) ;
@@ -40,13 +40,12 @@ module.exports = function( grunt ) {
40
40
41
41
function applyPatch ( patchUrl , done , options ) {
42
42
grunt . verbose . write ( patchUrl ) ;
43
- parsedUrl = url . parse ( patchUrl ) ;
43
+ const parsedUrl = url . parse ( patchUrl ) ;
44
44
45
45
// What to do when either our patch is ready
46
46
grunt . event . once ( 'fileReady' , function ( level , moveToSrc ) {
47
- let patchOptions = { } ,
48
- patchArgs = [ ] ,
49
- patchProcess ;
47
+ const patchOptions = { } ;
48
+ const patchArgs = [ ] ;
50
49
51
50
// Set patch process to use the existing I/O streams, which will output
52
51
// the command's results and allow for user input on patch error
@@ -71,7 +70,7 @@ module.exports = function( grunt ) {
71
70
mapOldToNewFilePath ( tempFile , options . file_mappings ) ;
72
71
}
73
72
74
- patchProcess = spawn ( 'patch' , patchArgs , patchOptions ) ;
73
+ const patchProcess = spawn ( 'patch' , patchArgs , patchOptions ) ;
75
74
76
75
patchProcess . on ( 'exit' , function ( code , signal ) {
77
76
if ( signal ) {
@@ -145,11 +144,11 @@ module.exports = function( grunt ) {
145
144
146
145
grunt . log . debug ( 'getPatchFromTicket: ' + patchUrl ) ;
147
146
request ( patchUrl , function ( error , response , body ) {
148
- if ( ! error && 200 == response . statusCode ) {
147
+ if ( ! error && 200 === response . statusCode ) {
149
148
matches = regex . patchAttachments ( body ) ;
150
149
grunt . log . debug ( 'matches: ' + JSON . stringify ( matches ) ) ;
151
150
152
- if ( null == matches ) {
151
+ if ( null === matches ) {
153
152
grunt . event . emit ( 'fileFail' , patchUrl + '\ncontains no attachments' ) ;
154
153
} else if ( 1 === matches . length ) {
155
154
matchUrl = options . tracUrl + regex . urlsFromAttachmentList ( matches [ 0 ] ) [ 1 ] ;
@@ -197,7 +196,7 @@ module.exports = function( grunt ) {
197
196
function getPatch ( patchUrl ) {
198
197
grunt . log . debug ( 'getting patch: ' + patchUrl ) ;
199
198
request ( patchUrl , function ( error , response , body ) {
200
- if ( ! error && 200 == response . statusCode ) {
199
+ if ( ! error && 200 === response . statusCode ) {
201
200
const level = patch . isAb ( body ) ? 1 : 0 ;
202
201
const moveToSrc = patch . moveToSrc ( body ) ;
203
202
@@ -234,7 +233,7 @@ module.exports = function( grunt ) {
234
233
235
234
function localFile ( error , result , code , done , options ) {
236
235
if ( ! error ) {
237
- files = _ . filter ( result . split ( '\n' ) , function ( file ) {
236
+ const files = _ . filter ( result . split ( '\n' ) , function ( file ) {
238
237
return ( _ . str . include ( file , 'patch' ) || _ . str . include ( file , 'diff' ) ) ;
239
238
} ) ;
240
239
grunt . log . debug ( 'files: ' + JSON . stringify ( files ) ) ;
@@ -302,7 +301,7 @@ module.exports = function( grunt ) {
302
301
const uploadPatchWithCredentials = function ( username , password ) {
303
302
const diffCommand = isSvn ( ) ? 'svn diff --diff-cmd diff' : 'git diff' ;
304
303
305
- exec ( diffCommand , function ( error , result , code ) {
304
+ exec ( diffCommand , function ( error , result ) {
306
305
const client = xmlrpc . createSecureClient ( {
307
306
hostname : options . tracUrl ,
308
307
port : 443 ,
@@ -320,7 +319,7 @@ module.exports = function( grunt ) {
320
319
'' , // description. empty for now.
321
320
new Buffer ( new Buffer ( result ) . toString ( 'base64' ) , 'base64' ) ,
322
321
false , // never overwrite the old file
323
- ] , function ( err , value ) {
322
+ ] , function ( err ) {
324
323
if ( null === err ) {
325
324
grunt . log . writeln ( 'Uploaded patch.' ) ;
326
325
done ( ) ;
0 commit comments