Permalink
Browse files

Fix for #70 - New version 0.6.3

  • Loading branch information...
1 parent 5076f1b commit 1e5ebeb47fdeab8b8cc10aa237378173e52b0aac @jefflembeck jefflembeck committed Aug 1, 2013
Showing with 16 additions and 10 deletions.
  1. +1 −1 Gruntfile.js
  2. +5 −3 lib/pngcrusher.js
  3. +1 −1 package.json
  4. +9 −5 tasks/grunticon.js
View
@@ -39,7 +39,7 @@ module.exports = function(grunt) {
loadersnippet: "grunticon.loader.txt",
// folder name (within dest) for png output
- pngfolder: "png/",
+ pngfolder: "png",
// prefix for CSS classnames
cssprefix: "icon-",
View
@@ -13,7 +13,7 @@
path = require( "path" );
absolute = path.resolve;
exists = fs.existsSync;
- makeDir = fs.mkdirSync;
+ makeDir = fs.mkdirpSync;
removeTree = function( path , callback ){
fs.remove( path , callback );
};
@@ -34,11 +34,13 @@
isDirectory = fs.isDirectory;
}
- exports.makeOutputDir = function( outputDir , isDir ){
+ exports.makeOutputDir = function( outputDir , inputIsDir ){
var output = absolute( outputDir );
+ // If it does not exist, make it!
if( !exists( output ) ){
makeDir( output );
- } else if( isDir ){
+ //if it exists and the input is a dir, remove it and make it
+ } else if( inputIsDir ){
removeTree( output , function(){
makeDir( output );
});
View
@@ -1,7 +1,7 @@
{
"name": "grunt-grunticon",
"description": "A mystical CSS icon solution",
- "version": "0.6.2",
+ "version": "0.6.3",
"homepage": "https://github.com/filamentgroup/grunticon",
"author": {
"name": "Scott Jehl",
View
@@ -133,7 +133,9 @@ module.exports = function( grunt , undefined ) {
var customselectors = JSON.stringify( config.customselectors ) || "{}";
// folder name (within the output folder) for generated png files
- var pngfolder = config.pngfolder || "png" + path.sep;
+ var pngfolder = config.pngfolder || "png";
+ pngfolder = path.join.apply( null, pngfolder.split( path.sep ) );
+
// make sure pngfolder has / at the end
if( !pngfolder.match( path.sep + '$' ) ){
pngfolder += path.sep;
@@ -196,7 +198,7 @@ module.exports = function( grunt , undefined ) {
grunt.fatal( err );
done( false );
}
- return writeFile( tmp + file , result );
+ return writeFile( path.join( tmp , file) , result );
})
.then( function( _null , err ){
if( err ){
@@ -272,13 +274,14 @@ module.exports = function( grunt , undefined ) {
grunt.log.write('(using path: ' + crushPath + ')');
var render = false;
var writeCSS = true;
+ var tmpPngfolder = path.join( tmp, pngfolder );
if( grunt.file.exists( path.join( config.dest , pngfolder ) ) ){
grunt.file.delete( path.join( config.dest, pngfolder ) );
}
crusher.crush({
- input: tmp + pngfolder,
- outputDir: config.dest + pngfolder,
+ input: tmpPngfolder,
+ outputDir: path.join( config.dest , pngfolder ),
crushPath: crushPath
}, function( stdout , stderr ){
grunt.verbose.write( stdout );
@@ -291,6 +294,7 @@ module.exports = function( grunt , undefined ) {
done( false );
} else {
grunt.log.write( result.stdout );
+ grunt.file.delete( tmpPngfolder );
grunt.file.delete( tmp );
done();
}
@@ -311,7 +315,7 @@ module.exports = function( grunt , undefined ) {
if( render && writeCSS ){
pngpath = pngfolder;
} else {
- pngpath = path.join( "tmp", "png", path.sep );
+ pngpath = path.join( "tmp", pngfolder , path.sep );
}
callPhantom( pngpath, render, writeCSS, function(err, result, code) {
// TODO boost this up a bit.

0 comments on commit 1e5ebeb

Please sign in to comment.