Permalink
Browse files

Removed grunt helpers

refs #5
  • Loading branch information...
1 parent 7928d85 commit 12dde1e1985ede2c0037708cf964f992d8d28d85 oncletom committed Nov 14, 2012
Showing with 68 additions and 51 deletions.
  1. +22 −0 lib/crx-manifest.js
  2. +40 −0 lib/crx.js
  3. +1 −1 package.json
  4. +5 −50 tasks/crx.js
View
@@ -0,0 +1,22 @@
+"use strict";
+
+var path = require('path');
+
+exports.init = function(grunt){
+ var exports = {};
+
+ exports.build = function build(ChromeExtension, callback) {
+ if (!ChromeExtension.manifest.update_url || !ChromeExtension.codebase){
+ return callback();
+ }
+
+ ChromeExtension.generateUpdateXML();
+ var dest = path.dirname(ChromeExtension.dest);
+
+ grunt.file.write(path.join(dest, path.basename(ChromeExtension.manifest.update_url)), ChromeExtension.updateXML);
+
+ callback();
+ };
+
+ return exports;
+};
View
@@ -0,0 +1,40 @@
+"use strict";
+
+var exec = require('child_process').exec;
+var path = require('path');
+
+exports.init = function(grunt){
+ var exports = {};
+
+ exports.build = function build(ChromeExtension, callback) {
+ grunt.utils.async.series([
+ function(done){
+ ChromeExtension.load(done);
+ },
+ function(done){
+ if (!Array.isArray(ChromeExtension.exclude) || !ChromeExtension.exclude.length){
+ return done();
+ }
+
+ var files = grunt.file.expand(ChromeExtension.exclude.map(function(pattern){
+ return path.join(ChromeExtension.path, '/', pattern);
+ }));
+
+ exec('rm -rf '+ files.join(' '), done);
+ },
+ function(done){
+ ChromeExtension.pack(function(err, data){
+ if (err){
+ throw new grunt.task.taskError(err);
+ }
+
+ grunt.file.write(this.dest, data);
+
+ done();
+ });
+ }
+ ], callback);
+ };
+
+ return exports;
+};
View
@@ -1,7 +1,7 @@
{
"name": "grunt-crx",
"description": "Package your Chrome Extensions in a bliss.",
- "version": "0.1.1",
+ "version": "0.1.2",
"homepage": "https://github.com/oncletom/grunt-crx",
"author": {
"name": "oncletom",
View
@@ -9,7 +9,6 @@
var ChromeExtension = require('crx');
var path = require('path');
var fs = require('fs');
-var exec = require('child_process').exec;
/**
* Expand the current multitask config key name
@@ -66,6 +65,9 @@ function configure(defaults){
module.exports = function(grunt) {
+ var crx = require('./../lib/crx').init(grunt);
+ var crxManifest = require('./../lib/crx-manifest').init(grunt);
+
// ==========================================================================
// TASKS
// ==========================================================================
@@ -101,11 +103,11 @@ module.exports = function(grunt) {
grunt.utils.async.series([
// Building extension
function(callback){
- grunt.helper('crx', extension, callback);
+ crx.build(extension, callback);
},
// Building manifest
function(callback){
- grunt.helper('crx-manifest', extension, callback);
+ crxManifest.build(extension, callback);
},
// Clearing stuff
function(callback){
@@ -115,51 +117,4 @@ module.exports = function(grunt) {
}
], /* Baking done! */ done);
});
-
- // ==========================================================================
- // HELPERS
- // ==========================================================================
-
- grunt.registerHelper('crx', function(ChromeExtension, callback) {
- grunt.utils.async.series([
- function(done){
- ChromeExtension.load(done);
- },
- function(done){
- if (!Array.isArray(ChromeExtension.exclude) || !ChromeExtension.exclude.length){
- return done();
- }
-
- var files = grunt.file.expand(ChromeExtension.exclude.map(function(pattern){
- return path.join(ChromeExtension.path, '/', pattern);
- }));
-
- exec('rm -rf '+ files.join(' '), done);
- },
- function(done){
- ChromeExtension.pack(function(err, data){
- if (err){
- throw new grunt.task.taskError(err);
- }
-
- grunt.file.write(this.dest, data);
-
- done();
- });
- }
- ], callback);
- });
-
- grunt.registerHelper('crx-manifest', function(ChromeExtension, callback) {
- if (!ChromeExtension.manifest.update_url || !ChromeExtension.codebase){
- return callback();
- }
-
- ChromeExtension.generateUpdateXML();
- var dest = path.dirname(ChromeExtension.dest);
-
- grunt.file.write(path.join(dest, path.basename(ChromeExtension.manifest.update_url)), ChromeExtension.updateXML);
-
- callback();
- });
};

0 comments on commit 12dde1e

Please sign in to comment.