aboutsummaryrefslogtreecommitdiff
path: root/grunt/tasks/css-flip.js
blob: 29cfb4038b43ca854a75fdc35f3d258d840757f8 (plain)
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
/*!
 * Bootstrap Grunt task for generating RTL CSS from LTR CSS using css-flip
 * http://getbootstrap.com
 * Copyright 2014 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 */
'use strict';

var flip = require('css-flip');


module.exports = function(grunt) {
  grunt.registerMultiTask('cssFlip', 'Generates RTL CSS from LTR CSS using css-flip', function () {
    this.files.forEach(function (f) {
      var unflippedCss = grunt.file.read(f.src);
      var flippedCss = null;
      try {
        flippedCss = flip(unflippedCss);
      }
      catch (err) {
        grunt.fail.warn(err);
      }
      grunt.file.write(f.dest, flippedCss);
      grunt.log.writeln('File ' + f.dest.cyan + ' created.');
    });
  });
};