htmlhero avatar htmlhero committed 79c7f5b

Update to grunt 0.4.1

Comments (0)

Files changed (5)

 syntax: glob
+.idea
+.DS_Store
 node_modules
+module.exports = function (grunt) {
+
+	// Project configuration.
+	grunt.initConfig({
+		jshint: {
+			options: {
+				curly: true,
+				eqeqeq: true,
+				immed: true,
+				latedef: true,
+				newcap: true,
+				noarg: true,
+				sub: true,
+				undef: true,
+				boss: true,
+				eqnull: true,
+				node: true,
+				es5: true
+			},
+			all: [
+				'Gruntfile.js',
+				'tasks/**/*.js',
+				'test/**/*.js'
+			]
+		},
+		nodeunit: {
+			all: ['test/**/*.js']
+		},
+		compress: {
+			all: {
+				options: {
+					archive: 'archive.zip'
+				}
+			}
+		},
+		watch: {
+			files: '<%= jshint.all %>',
+			tasks: 'default'
+		}
+	});
+
+	// Load local tasks.
+	grunt.loadNpmTasks('grunt-contrib-jshint');
+	grunt.loadNpmTasks('grunt-contrib-nodeunit');
+	grunt.loadNpmTasks('grunt-contrib-watch');
+
+	// Default task.
+	grunt.registerTask('default', ['jshint']);
+
+};

grunt.js

-module.exports = function(grunt) {
-
-  // Project configuration.
-  grunt.initConfig({
-    test: {
-      files: ['test/**/*.js']
-    },
-    lint: {
-      files: ['grunt.js', 'tasks/**/*.js', 'test/**/*.js']
-    },
-    watch: {
-      files: '<config:lint.files>',
-      tasks: 'default'
-    },
-    jshint: {
-      options: {
-        curly: true,
-        eqeqeq: true,
-        immed: true,
-        latedef: true,
-        newcap: true,
-        noarg: true,
-        sub: true,
-        undef: true,
-        boss: true,
-        eqnull: true,
-        node: true,
-        es5: true
-      },
-      globals: {}
-    }
-  });
-
-  // Load local tasks.
-  grunt.loadTasks('tasks');
-
-  // Default task.
-  grunt.registerTask('default', 'lint test');
-
-};
       "url": "https://bitbucket.org/interfaced/grunt-samsung-widgetlist/src/tip/LICENSE-MIT"
     }
   ],
-  "main": "grunt.js",
   "bin": "bin/grunt-samsung-widgetlist",
   "engines": {
     "node": "*"
     "test": "grunt test"
   },
   "dependencies": {
+    "grunt": "~0.4.1",
     "xmlbuilder": "~0.4.2",
-    "archiver": "~0.1"
+    "archiver": "~0.1",
+    "grunt-contrib-nodeunit": "~0.1.2",
+    "grunt-contrib-jshint": "~0.4.3",
+    "grunt-contrib-watch": "~0.3.1"
   },
   "keywords": [
     "gruntplugin"

tasks/samsung-widgetlist.js

  * grunt-samsung-widgetlist
  * https://bitbucket.org/interfaced/grunt-samsung-widgetlist/overview
  *
- * Copyright (c) 2012 Interfaced
+ * Copyright (c) 2013 Interfaced
  * Licensed under the MIT license.
  */
 
 module.exports = function (grunt) {
 
-	// Please see the grunt documentation for more information regarding task and
-	// helper creation: https://github.com/cowboy/grunt/blob/master/docs/toc.md
-
 	var path = require('path'),
 		fs = require('fs'),
 		builder = require('xmlbuilder'),
 		archiver = require('archiver'),
 		fileInfoExp = /^([a-z0-9]+)_([0-9\.]+)_([0-9a-z]+)_([0-9]{8})$/i;
 
-	// TODO: remove this when grunt v0.4 is released
-	grunt.file.exists = grunt.file.exists || fs.existsSync || path.existsSync;
-
-	grunt.registerMultiTask('widgetlist', 'Build widgetlist.xml from given widgets archives.', function () {
+	grunt.registerMultiTask('widget-xml', 'Build widgetlist.xml from given widgets archives.', function () {
 		var configPrefix = [this.name, this.target, ''].join('.');
 		this.requiresConfig(
 			configPrefix + 'output',
 		grunt.log.ok();
 	});
 
-	grunt.registerMultiTask('widget', 'Build widgets archives.', function () {
+	grunt.registerMultiTask('widget-zip', 'Build widgets archives.', function () {
 		var files, source, done;
 		files = [];
 
-		for (source in this.data) if (this.data.hasOwnProperty(source)) {
-			files.push({
-				destination: grunt.template.process(this.data[source]),
-				source: grunt.template.process(source)
-			});
+		for (source in this.data) {
+			if (this.data.hasOwnProperty(source)) {
+				files.push({
+					destination: grunt.template.process(this.data[source]),
+					source: grunt.template.process(source)
+				});
+			}
 		}
 
 		done = this.async();
 		};
 
 		grunt.util.async.forEachSeries(files, function(file, next) {
-			grunt.helper('widget-zip', file.source, file.destination, next);
+			archiving(file.source, file.destination, next);
 		}, finishTask);
+
+		function archiving(sourceDirectory, destination, done) {
+			var zip, files, filenameMap;
+
+			zip = archiver.createZip({level: 1});
+			files = [];
+			filenameMap = {};
+
+			grunt.file.recurse(sourceDirectory, function(abspath, rootdir, subdir, filename) {
+				files.push(abspath);
+				filenameMap[abspath] = (subdir ? subdir + '/' : '') + filename;
+			});
+
+			zip.pipe(fs.createWriteStream(destination));
+
+			function addFile() {
+				if (!files.length) {
+					zip.finalize(function(written) {
+						grunt.log.writeln('File ' + destination.cyan + ' created (' + written + ' bytes written).');
+						done();
+					});
+					return;
+				}
+				var absPath = files.shift();
+				zip.addFile(fs.createReadStream(absPath), {name: filenameMap[absPath]}, addFile);
+			}
+
+			addFile();
+
+			zip.on('error', function(e) {
+				grunt.log.error(e);
+				grunt.fail.warn('zip process failed.');
+			});
+		}
+
 	});
 
-	grunt.registerHelper('widget-zip', function(sourceDirectory, destination, done) {
-		var zip, files, filenameMap;
-
-		zip = archiver.createZip({level: 1});
-		files = [];
-		filenameMap = {};
-
-		grunt.file.recurse(sourceDirectory, function(abspath, rootdir, subdir, filename) {
-			files.push(abspath);
-			filenameMap[abspath] = (subdir ? subdir + '/' : '') + filename;
-		});
-
-		zip.pipe(fs.createWriteStream(destination));
-
-		function addFile() {
-			if (!files.length) {
-				zip.finalize(function(written) {
-					grunt.log.writeln('File ' + destination.cyan + ' created (' + written + ' bytes written).');
-					done();
-				});
-				return;
-			}
-			var absPath = files.shift();
-			zip.addFile(fs.createReadStream(absPath), {name: filenameMap[absPath]}, addFile);
-		}
-
-		addFile();
-
-		zip.on('error', function(e) {
-			grunt.log.error(e);
-			grunt.fail.warn('zipHelper failed.');
-		});
-	});
 };
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.