grunt-cssjanus
Advanced tools
Comparing version 0.2.4 to 0.3.2
@@ -1,2 +0,2 @@ | ||
/* | ||
/** | ||
* grunt-cssjanus | ||
@@ -8,27 +8,44 @@ * https://github.com/cssjanus/grunt-cssjanus | ||
*/ | ||
'use strict'; | ||
module.exports = function(grunt) { | ||
module.exports = function ( grunt ) { | ||
grunt.loadTasks( 'tasks' ); | ||
grunt.loadNpmTasks( 'grunt-contrib-jshint' ); | ||
grunt.loadNpmTasks( 'grunt-jscs' ); | ||
// Project configuration. | ||
grunt.initConfig({ | ||
grunt.initConfig( { | ||
jshint: { | ||
options: { | ||
jshintrc: true | ||
}, | ||
src: '.' | ||
}, | ||
jscs: { | ||
src: '.' | ||
}, | ||
cssjanus: { | ||
options: { | ||
swapLtrRtlInUrl: true, | ||
swapLeftRightInUrl: false, | ||
generateExactDuplicates: false | ||
}, | ||
'fixtures/actual.css': 'fixtures/input.css' | ||
} | ||
} ); | ||
// Configuration to be run. | ||
cssjanus: { | ||
options: { | ||
swapLtrRtlInUrl: true, | ||
swapLeftRightInUrl: false, | ||
generateExactDuplicates: false | ||
}, | ||
}, | ||
grunt.registerTask( 'match', function () { | ||
var actual = grunt.file.read( 'fixtures/actual.css' ), | ||
expected = grunt.file.read( 'fixtures/expected.css' ); | ||
if ( actual !== expected ) { | ||
grunt.log.error( 'Test result mismatch.' ); | ||
grunt.log.subhead( 'Actual' ); | ||
grunt.log.write( actual ); | ||
grunt.log.subhead( 'Expected' ); | ||
grunt.log.write( expected ); | ||
return false; | ||
} | ||
grunt.log.ok( 'Test result matches expectation.' ); | ||
} ); | ||
}); | ||
// Actually load this plugin's task(s). | ||
grunt.loadTasks('tasks'); | ||
// By default, lint and run all tests. | ||
grunt.registerTask('default', ['cssjanus']); | ||
grunt.registerTask( 'default', [ 'jshint', 'jscs', 'cssjanus', 'match' ] ); | ||
}; |
{ | ||
"name": "grunt-cssjanus", | ||
"version": "0.3.2", | ||
"description": "Grunt plugin to convert CSS stylesheets between left-to-right and right-to-left", | ||
"version": "0.2.4", | ||
"homepage": "https://github.com/cssjanus/grunt-cssjanus", | ||
@@ -18,12 +18,9 @@ "author": { | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/cssjanus/grunt-cssjanus/blob/master/LICENSE-MIT" | ||
} | ||
], | ||
"main": "Gruntfile.js", | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">= 0.8.0" | ||
}, | ||
"scripts": { | ||
"test": "grunt" | ||
}, | ||
"dependencies": { | ||
@@ -33,6 +30,9 @@ "cssjanus": ">=1.1.2" | ||
"devDependencies": { | ||
"grunt": "~0.4.1" | ||
"grunt": "^0.4.2", | ||
"grunt-cli": "^0.1.13", | ||
"grunt-contrib-jshint": "^1.0.0", | ||
"grunt-jscs": "^2.7.0" | ||
}, | ||
"peerDependencies": { | ||
"grunt": "~0.4.1" | ||
"grunt": ">=0.4.0" | ||
}, | ||
@@ -39,0 +39,0 @@ "keywords": [ |
@@ -0,1 +1,3 @@ | ||
[![Build Status](https://travis-ci.org/cssjanus/grunt-cssjanus.svg?branch=master)](https://travis-ci.org/cssjanus/grunt-cssjanus) [![npm](https://img.shields.io/npm/v/grunt-cssjanus.svg?style=flat)](https://www.npmjs.com/package/grunt-cssjanus) | ||
# grunt-cssjanus | ||
@@ -6,3 +8,3 @@ | ||
## Getting Started | ||
This plugin requires Grunt `~0.4.1` | ||
This plugin requires Grunt `0.4` or higher | ||
@@ -22,2 +24,3 @@ If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command: | ||
### Options | ||
_Run this task with the `grunt cssjanus` command._ | ||
@@ -48,9 +51,28 @@ #### options.swapLtrRtlInUrl | ||
## Usage | ||
This plugin uses the standard Grunt multi task for file operations. See [Configuring tasks](http://gruntjs.com/configuring-tasks#task-configuration-and-targets) for all supported options and formats. | ||
### Basic distribution | ||
```js | ||
grunt.initConfig({ | ||
cssjanus: { | ||
build: { | ||
files: { | ||
'dist/head.rtl.css': 'src/head.css', | ||
'dist/main.rtl.css': 'src/main.css' | ||
} | ||
} | ||
} | ||
}); | ||
``` | ||
## Release History | ||
0.2.3 - Update minimum cssjanus version to 1.1.2 | ||
0.3.0 - Extend version range of Grunt peerDependency | ||
0.2.3 - Update minimum cssjanus version | ||
0.2.4 - Update minimum cssjanus version to 1.1.2 | ||
0.2.3 - Update minimum cssjanus version to 1.1.1 | ||
0.2.2 - Revert to using the standard cssjanus 1.0.2 module | ||
@@ -57,0 +79,0 @@ |
@@ -1,2 +0,2 @@ | ||
/* | ||
/** | ||
* grunt-cssjanus | ||
@@ -8,44 +8,47 @@ * https://github.com/cssjanus/grunt-cssjanus | ||
*/ | ||
'use strict'; | ||
module.exports = function(grunt) { | ||
module.exports = function ( grunt ) { | ||
var cssjanus = require( 'cssjanus' ); | ||
grunt.registerMultiTask('cssjanus', 'Flip a css file direction from LTR to RTL', function() { | ||
var options = this.options({ | ||
swapLtrRtlInUrl: true, | ||
swapLeftRightInUrl: false, | ||
processContent: false, | ||
}); | ||
// Iterate over all specified file groups. | ||
this.files.forEach(function(f) { | ||
// flip specified files. | ||
var src = f.src.filter(function(filepath) { | ||
// Warn on and remove invalid source files (if nonull was set). | ||
if (!grunt.file.exists(filepath)) { | ||
grunt.log.warn('Source file "' + filepath + '" not found.'); | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
}).map(function(filepath) { | ||
// Read file source. | ||
return grunt.file.read(filepath); | ||
}).join(grunt.util.normalizelf(grunt.util.linefeed)); | ||
grunt.registerMultiTask( 'cssjanus', 'Flip a css file direction from LTR to RTL', function () { | ||
var options = this.options( { | ||
swapLtrRtlInUrl: true, | ||
swapLeftRightInUrl: false, | ||
processContent: false | ||
} ); | ||
// Iterate over all specified file groups | ||
this.files.forEach( function ( f ) { | ||
var src, rtlcss; | ||
// Flip specified files | ||
src = f.src | ||
.filter( function ( filepath ) { | ||
// Warn on and remove invalid source files (if nonull was set) | ||
if ( !grunt.file.exists( filepath ) ) { | ||
grunt.log.warn( 'Source file "' + filepath + '" not found.' ); | ||
return false; | ||
} | ||
return true; | ||
} ) | ||
.map( function ( filepath ) { | ||
// Read file source | ||
return grunt.file.read( filepath ); | ||
} ) | ||
.join( grunt.util.normalizelf( grunt.util.linefeed ) ); | ||
var cssjanus = require( 'cssjanus' ); | ||
var rtlcss = cssjanus.transform( src, options.swapLtrRtlInUrl, options.swapLeftRightInUrl ); | ||
if ( options.processContent ) { | ||
rtlcss = options.processContent( rtlcss ); | ||
} | ||
if ( ! options.generateExactDuplicates && rtlcss == src ) { | ||
grunt.log.writeln('Nothing to flip in ' + f.src ); | ||
} else { // Write the destination file. | ||
grunt.file.write(f.dest, rtlcss); | ||
grunt.log.writeln('File "' + f.dest + '" created.'); | ||
} | ||
rtlcss = cssjanus.transform( src, options.swapLtrRtlInUrl, options.swapLeftRightInUrl ); | ||
if ( options.processContent ) { | ||
rtlcss = options.processContent( rtlcss ); | ||
} | ||
if ( !options.generateExactDuplicates && rtlcss === src ) { | ||
grunt.log.writeln( 'Nothing to flip in ' + f.src ); | ||
} else { | ||
// Write the destination file | ||
grunt.file.write( f.dest, rtlcss ); | ||
grunt.log.writeln( 'File "' + f.dest + '" created.' ); | ||
} | ||
}); | ||
}); | ||
} ); | ||
} ); | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8287
12
110
90
4