grunt-po2mo
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -33,6 +33,13 @@ /* | ||
po2mo: { | ||
files: { | ||
stage: { | ||
src: 'test/fixtures/fr.po', | ||
dest: 'tmp/fr.mo', | ||
}, | ||
prod: { | ||
options: { | ||
deleteSrc: true | ||
}, | ||
src: 'tmp/fixtures/fr.po', | ||
dest: 'tmp/fr.mo' | ||
} | ||
}, | ||
@@ -55,5 +62,9 @@ | ||
grunt.registerTask('copy', 'Copy fixtures to a temp location.', function() { | ||
grunt.file.copy('test/fixtures/fr.po', 'tmp/fixtures/fr.po'); | ||
}); | ||
// Whenever the "test" task is run, first clean the "tmp" dir, then run this | ||
// plugin's task(s), then test the result. | ||
grunt.registerTask('test', ['clean', 'po2mo', 'nodeunit']); | ||
grunt.registerTask('test', ['clean', 'copy', 'po2mo', 'nodeunit']); | ||
@@ -60,0 +71,0 @@ // By default, lint and run all tests. |
{ | ||
"name": "grunt-po2mo", | ||
"description": "Compile .po files into binary .mo files with msgfmt.", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"homepage": "https://github.com/MicheleBertoli/grunt-po2mo", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -8,3 +8,5 @@ [![Build Status](https://travis-ci.org/MicheleBertoli/grunt-po2mo.svg)](https://travis-ci.org/MicheleBertoli/grunt-po2mo) | ||
## Getting Started | ||
This plugin requires Grunt `~0.4.1` | ||
This plugin requires: | ||
- Grunt `~0.4.1` | ||
- [gettext](https://www.gnu.org/software/gettext/) (Installation instructions: [Mac](http://brewformulas.org/Gettext), [Windows](http://gnuwin32.sourceforge.net/packages/gettext.htm) and [Linux](http://ftp.gnu.org/pub/gnu/gettext/)) | ||
@@ -38,2 +40,10 @@ 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 | ||
#### options.deleteSrc | ||
Type: `Boolean` | ||
Default value: `false` | ||
Will delete the source .po file. | ||
### Usage Examples | ||
@@ -55,4 +65,7 @@ | ||
files: { | ||
src: 'languages/*.po', | ||
expand: true, | ||
options: { | ||
deleteSrc: true | ||
}, | ||
src: 'languages/fr.po', | ||
dest: 'languages/fr.mo', | ||
}, | ||
@@ -59,0 +72,0 @@ }, |
@@ -17,4 +17,9 @@ /* | ||
var options = this.options({ | ||
deleteSrc: false, | ||
}); | ||
this.files.forEach(function(file) { | ||
var src = file.src[0]; | ||
var dest = file.dest; | ||
@@ -26,3 +31,3 @@ if (dest.indexOf('.po') > -1) { | ||
var command = 'msgfmt -o ' + dest + ' ' + file.src[0]; | ||
var command = 'msgfmt -o ' + dest + ' ' + src; | ||
@@ -37,2 +42,6 @@ grunt.verbose.writeln('Executing: ' + command); | ||
if (options.deleteSrc) { | ||
grunt.file.delete(src); | ||
} | ||
}); | ||
@@ -39,0 +48,0 @@ |
@@ -9,3 +9,3 @@ 'use strict'; | ||
}, | ||
files: function(test) { | ||
stage: function(test) { | ||
test.expect(1); | ||
@@ -19,2 +19,10 @@ | ||
}, | ||
prod: function(test) { | ||
test.expect(1); | ||
var expected = grunt.file.exists('tmp/fixtures/fr.po'); | ||
test.equal(expected, false); | ||
test.done(); | ||
}, | ||
}; |
Sorry, the diff of this file is not supported yet
8146
113
75