Permalink
Browse files

Use fs.existsSync if available, adds proper support for node 0.8+.

  • Loading branch information...
1 parent 25c243a commit 146cdf86ab804a690b1140f7ac3e79143c705cf2 @scottgonzalez committed Jul 18, 2012
Showing with 13 additions and 7 deletions.
  1. +6 −3 tasks/wordpress/resources.js
  2. +7 −4 tasks/wordpress/taxonomies.js
@@ -1,8 +1,11 @@
module.exports = function( grunt ) {
-var path = require( "path" ),
+var fs = require( "fs" ),
+ path = require( "path" ),
crypto = require( "crypto" ),
- async = grunt.utils.async;
+ async = grunt.utils.async,
+ // support: node <0.8
+ existsSync = fs.existsSync || path.existsSync;
function createChecksum( str ) {
var md5 = crypto.createHash( "md5" );
@@ -64,7 +67,7 @@ grunt.registerHelper( "wordpress-sync-resources", function( dir, fn ) {
grunt.verbose.writeln( "Synchronizing resources.".bold );
// Check if there are any resources to process
- if ( !path.existsSync( dir ) ) {
+ if ( !existsSync( dir ) ) {
grunt.verbose.writeln( "No resources to process." );
grunt.verbose.writeln();
return fn( null );
@@ -1,7 +1,10 @@
module.exports = function( grunt ) {
-var path = require( "path" ),
- async = grunt.utils.async;
+var fs = require( "fs" ),
+ path = require( "path" ),
+ async = grunt.utils.async,
+ // support: node <0.8
+ existsSync = fs.existsSync || path.existsSync;
// Converts a term to a readable name, e.g., { taxonomy: "foo", slug: "bar" } to "foo bar"
function prettyTermName( term ) {
@@ -21,7 +24,7 @@ grunt.registerHelper( "wordpress-validate-terms", function( filepath, fn ) {
fn( null );
}
- if ( !path.existsSync( filepath ) ) {
+ if ( !existsSync( filepath ) ) {
return complete();
}
@@ -182,7 +185,7 @@ grunt.registerHelper( "wordpress-sync-terms", function( filepath, fn ) {
grunt.verbose.writeln( "Synchronizing terms.".bold );
// Check if there are any terms to process
- if ( !path.existsSync( filepath ) ) {
+ if ( !existsSync( filepath ) ) {
grunt.verbose.writeln( "No terms to process." );
grunt.verbose.writeln();
return fn( null );

0 comments on commit 146cdf8

Please sign in to comment.