jenkins-bot has submitted this change and it was merged.

Change subject: build: Use grunt-contrib-copy instead of custom 'copy' task
......................................................................


build: Use grunt-contrib-copy instead of custom 'copy' task

For our current build, it doesn't offer much. But this is in
prep for copying larger structures and edge cases (T90120) that
are much better implemented in this library.

Minor benefits:

* Performs slightly faster (YMMMV).

* Maintained by upstream.
  At least one minor bug is effectively fixed by this
  ("Copied 1 files > Copied 1 file")

* Match file descriptor syntax with that of other tasks (using
  standard Grunt file patterns instead of our own). This means
  they all work the same way  now (e.g. no more inconsistent
  handling of ** flattening or not, and trailing slash). This
  also addresses the weird behaviour where a copy would sometimes
  result in all files in the src directory being copied to a
  single target file taht was meant to be directory.

We are losing our built-in 'strip'. Created a rename function
in its place for now. I'd like to revise this setup more
generally, though. Our build can be simpler.

Change-Id: I49bc4be1dc564d195c9dbeec8ba4a6d8ca7780a5
---
M Gruntfile.js
D build/tasks/copy.js
M package.json
3 files changed, 28 insertions(+), 29 deletions(-)

Approvals:
  Bartosz Dziewoński: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Gruntfile.js b/Gruntfile.js
index edc713d..c4ea5e9 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -7,6 +7,7 @@
        grunt.loadNpmTasks( 'grunt-banana-checker' );
        grunt.loadNpmTasks( 'grunt-contrib-clean' );
        grunt.loadNpmTasks( 'grunt-contrib-concat-sourcemaps' );
+       grunt.loadNpmTasks( 'grunt-contrib-copy' );
        grunt.loadNpmTasks( 'grunt-contrib-csslint' );
        grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
        grunt.loadNpmTasks( 'grunt-contrib-jshint' );
@@ -75,6 +76,15 @@
                }
 
                return target;
+       }
+
+       function strip( str ) {
+               var path = require( 'path' );
+               // 
http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically
+               // http://gruntjs.com/api/grunt.file#grunt.file.expandmapping
+               return function ( dest, src ) {
+                       return path.join( dest, src.replace( str, '' ) );
+               };
        }
 
        grunt.initConfig( {
@@ -185,32 +195,38 @@
                copy: {
                        imagesCommon: {
                                src: 'src/styles/images/*.cur',
-                               strip: 'src/styles/images/',
-                               dest: 'dist/images'
+                               dest: 'dist/images/',
+                               expand: true,
+                               flatten: true
                        },
                        imagesApex: {
                                src: 'src/themes/apex/images/**/*.{png,gif}',
-                               strip: 'src/themes/apex/images',
-                               dest: 'dist/themes/apex/images'
+                               dest: 'dist/themes/apex/images/',
+                               expand: true,
+                               rename: strip( 'src/themes/apex/images/' )
                        },
                        imagesMediaWiki: {
                                src: 
'src/themes/mediawiki/images/**/*.{png,gif}',
-                               strip: 'src/themes/mediawiki/images',
-                               dest: 'dist/themes/mediawiki/images'
+                               dest: 'dist/themes/mediawiki/images/',
+                               expand: true,
+                               rename: strip( 'src/themes/mediawiki/images/' )
                        },
                        i18n: {
                                src: 'i18n/*.json',
-                               dest: 'dist'
+                               expand: true,
+                               dest: 'dist/'
                        },
                        lessTemp: {
                                src: 'src/**/*.less',
-                               strip: 'src/',
-                               dest: 'dist/tmp'
+                               dest: 'dist/tmp/',
+                               expand: true,
+                               rename: strip( 'src/' )
                        },
                        svg: {
                                src: 'dist/tmp/**/*.svg',
-                               strip: 'dist/tmp/',
-                               dest: 'dist'
+                               dest: 'dist/',
+                               expand: true,
+                               rename: strip( 'dist/tmp/' )
                        }
                },
                colorizeSvg: {
diff --git a/build/tasks/copy.js b/build/tasks/copy.js
deleted file mode 100644
index 59077c9..0000000
--- a/build/tasks/copy.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/*!
- * Copy files and directory structure from 'src' to 'dest', stripping the 
'strip' path prefix.
- */
-
-/*jshint node:true */
-module.exports = function ( grunt ) {
-
-       grunt.registerMultiTask( 'copy', function () {
-               var destDir = this.data.dest + '/',
-                       strip = this.data.strip;
-               this.filesSrc.forEach( function ( fileName ) {
-                       var destFileName = strip ? fileName.replace( strip, '' 
) : fileName;
-                       grunt.file.copy( fileName, destDir + destFileName );
-               } );
-               grunt.log.writeln( 'Copied ' + this.filesSrc.length + ' files.' 
);
-       } );
-
-};
diff --git a/package.json b/package.json
index e1c8321..fc811b4 100644
--- a/package.json
+++ b/package.json
@@ -27,6 +27,7 @@
     "grunt-banana-checker": "0.2.0",
     "grunt-contrib-clean": "0.6.0",
     "grunt-contrib-concat-sourcemaps": "0.6.0",
+    "grunt-contrib-copy": "0.8.0",
     "grunt-contrib-csslint": "0.4.0",
     "grunt-contrib-cssmin": "0.12.1",
     "grunt-contrib-jshint": "0.11.0",

-- 
To view, visit https://gerrit.wikimedia.org/r/191876
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I49bc4be1dc564d195c9dbeec8ba4a6d8ca7780a5
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to