Permalink
Browse files

Start converting to plain JS.

  • Loading branch information...
1 parent 2223ff0 commit b7caed403f3ca76235659a6f2f95ab134b64a006 @rubenv committed Nov 20, 2013
Showing with 67 additions and 52 deletions.
  1. +24 −0 .jshintrc
  2. +8 −18 Gruntfile.coffee
  3. +2 −1 package.json
  4. +33 −33 tasks/compile.js
View
24 .jshintrc
@@ -0,0 +1,24 @@
+{
+ "curly": true,
+ "eqeqeq": true,
+ "immed": true,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "sub": true,
+ "undef": true,
+ "boss": true,
+ "eqnull": true,
+ "node": true,
+ "white": true,
+ "predef": [
+ "$",
+ "angular",
+ "describe",
+ "it",
+ "before",
+ "beforeEach",
+ "after",
+ "afterEach"
+ ]
+}
View
26 Gruntfile.coffee
@@ -1,34 +1,25 @@
module.exports = (grunt) ->
@loadNpmTasks('grunt-contrib-clean')
- @loadNpmTasks('grunt-contrib-coffee')
+ @loadNpmTasks('grunt-contrib-jshint')
@loadNpmTasks('grunt-contrib-watch')
@loadNpmTasks('grunt-mocha-cli')
@loadNpmTasks('grunt-release')
@loadTasks('tasks')
@initConfig
- coffee:
- tasks:
- options:
- bare: true
- expand: true
- cwd: 'src'
- src: ['*.coffee']
- dest: 'tasks'
- ext: '.js'
+ jshint:
+ all: [ 'tasks/*.js' ]
+ options:
+ jshintrc: '.jshintrc'
clean:
- tasks: ['tasks']
tmp: ['tmp']
watch:
- all:
- files: ['src/**.coffee']
- tasks: ['build']
test:
files: ['tasks/**.js', 'test/*{,/*}.coffee']
- tasks: ['runtests']
+ tasks: ['test']
mochacli:
options:
@@ -77,7 +68,6 @@ module.exports = (grunt) ->
'tmp/test3.js': 'test/fixtures/{nl,fr}.po'
@registerTask 'default', ['test']
- @registerTask 'build', ['clean', 'coffee']
+ @registerTask 'build', ['clean', 'jshint']
@registerTask 'package', ['build', 'release']
- @registerTask 'runtests', ['clean:tmp', 'nggettext_extract:auto', 'nggettext_extract:custom', 'nggettext_compile', 'mochacli']
- @registerTask 'test', ['build', 'runtests']
+ @registerTask 'test', ['build', 'nggettext_extract:auto', 'nggettext_extract:custom', 'nggettext_compile', 'mochacli']
View
3 package.json
@@ -35,7 +35,8 @@
"grunt-contrib-watch": "~0.5.1",
"grunt-mocha-cli": "~1.0.6",
"grunt-release": "~0.4.0",
- "coffee-script": "~1.6.3"
+ "coffee-script": "~1.6.3",
+ "grunt-contrib-jshint": "~0.7.2"
},
"peerDependencies": {
"grunt": "~0.4.1"
View
66 tasks/compile.js
@@ -1,40 +1,40 @@
-var langTemplate, po, template;
+var po = require('node-po');
-po = require('node-po');
-
-template = function(module, body) {
- return "angular.module(\"" + module + "\").run(['gettextCatalog', function (gettextCatalog) {\n" + body + "\n}]);";
+var template = function (module, body) {
+ return "angular.module(\"" + module + "\").run(['gettextCatalog', function (gettextCatalog) {\n" + body + "\n}]);";
};
-langTemplate = function(language, strings) {
- return " gettextCatalog.setStrings('" + language + "', " + (JSON.stringify(strings)) + ");\n";
+var langTemplate = function (language, strings) {
+ return " gettextCatalog.setStrings('" + language + "', " + (JSON.stringify(strings)) + ");\n";
};
-module.exports = function(grunt) {
- return grunt.registerMultiTask('nggettext_compile', 'Compile strings from .po files', function() {
- var options;
- options = this.options({
- module: 'gettext'
- });
- return this.files.forEach(function(file) {
- var body;
- body = '';
- file.src.forEach(function(input) {
- var catalog, data, item, strings, _i, _len, _ref;
- data = grunt.file.read(input);
- catalog = po.parse(data);
- if (!catalog.headers.Language) {
- throw new Error('No Language header found!');
- }
- strings = {};
- _ref = catalog.items;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- item = _ref[_i];
- strings[item.msgid] = item.msgstr.length === 1 ? item.msgstr[0] : item.msgstr;
- }
- return body += langTemplate(catalog.headers.Language, strings);
- });
- return grunt.file.write(file.dest, template(options.module, body));
+module.exports = function (grunt) {
+ grunt.registerMultiTask('nggettext_compile', 'Compile strings from .po files', function () {
+ var options = this.options({
+ module: 'gettext'
+ });
+
+ this.files.forEach(function (file) {
+ var body = '';
+
+ file.src.forEach(function (input) {
+ var data = grunt.file.read(input);
+ var catalog = po.parse(data);
+
+ if (!catalog.headers.Language) {
+ throw new Error('No Language header found!');
+ }
+
+ var strings = {};
+ for (var i = 0; i < catalog.items.length; i++) {
+ var item = catalog.items[i];
+ strings[item.msgid] = item.msgstr.length === 1 ? item.msgstr[0] : item.msgstr;
+ }
+
+ body += langTemplate(catalog.headers.Language, strings);
+ });
+
+ grunt.file.write(file.dest, template(options.module, body));
+ });
});
- });
};

0 comments on commit b7caed4

Please sign in to comment.