directory-encoder
Advanced tools
Comparing version 0.6.1 to 0.7.0
@@ -23,2 +23,7 @@ /*global require:true*/ | ||
} | ||
if( typeof output !== "string" ){ | ||
throw new Error( "Output must be file name of desired encoded file" ); | ||
} | ||
this.output = output; | ||
@@ -34,2 +39,4 @@ this.options = options || {}; | ||
this.template = this._loadTemplate( this.options.template ); | ||
this.templatePrepend = this.options.templatePrepend || ""; | ||
this.templateAppend = this.options.templateAppend || ""; | ||
} | ||
@@ -53,2 +60,5 @@ | ||
} | ||
// add templatePrepend to the output file | ||
fs.appendFileSync( self.output, self.templatePrepend ); | ||
@@ -78,2 +88,6 @@ // append each selector | ||
}); | ||
// add templateAppend to the output file | ||
fs.appendFileSync( self.output, self.templateAppend ); | ||
}; | ||
@@ -80,0 +94,0 @@ DirectoryEncoder.prototype._css = function( name, datauri, stats ) { |
{ | ||
"name": "directory-encoder", | ||
"description": "Encode a directory of images to CSS", | ||
"version": "0.6.1", | ||
"version": "0.7.0", | ||
"homepage": "https://github.com/filamentgroup/directory-encoder", | ||
@@ -33,12 +33,12 @@ "author": { | ||
"handlebars": "1.1.2", | ||
"lodash":"2.4.0", | ||
"lodash": "2.4.0", | ||
"img-stats": "0.4.2" | ||
}, | ||
"devDependencies": { | ||
"grunt-contrib-jshint": "~0.1.1", | ||
"grunt-contrib-nodeunit": "~0.1.2", | ||
"grunt-contrib-watch": "~0.2.0", | ||
"grunt": "~0.4.2" | ||
"grunt": "^0.4.5", | ||
"grunt-contrib-jshint": "^0.11.1", | ||
"grunt-contrib-nodeunit": "^0.4.1", | ||
"grunt-contrib-watch": "^0.6.1" | ||
}, | ||
"keywords": [] | ||
} |
@@ -17,3 +17,5 @@ # directory-encoder [![Build Status](https://secure.travis-ci.org/filamentgroup/directory-encoder.png?branch=master)](http://travis-ci.org/filamentgroup/directory-encoder) | ||
prefix: ".icon-", // used to prefix the name of the file for the CSS classname, .icon- is the default | ||
templatePrepend: "/* start of icon-list */", // this string is prepended to the destinationCSSFile, defaults to "" | ||
template: template.hbs, //template in handlebars, FANCY! | ||
templateAppend: "/* end of icon-list */", // this string is appended to the destinationCSSFile, defaults to "" | ||
noencodepng: false // turn this to true if you want no datauris | ||
@@ -59,2 +61,3 @@ for pngs, just links out to png files | ||
* 0.7.0 Add templateAppend and templatePrepend options | ||
* 0.6.0 Fix encoding brackets and ability to take an array | ||
@@ -61,0 +64,0 @@ * 0.5.0 PNGpath |
@@ -14,3 +14,64 @@ /*global require:true*/ | ||
exports['encode'] = { | ||
exports.constructor = { | ||
setUp: function( done ){ | ||
done(); | ||
}, | ||
tearDown: function( done ){ | ||
done(); | ||
}, | ||
noargs: function( test ){ | ||
test.expect(1); | ||
test.throws(function(){ | ||
new Constructor(); | ||
}, "Constructor should throw error if now arguments passed in"); | ||
test.done(); | ||
}, | ||
onearg: function( test ){ | ||
test.expect(1); | ||
test.throws(function(){ | ||
new Constructor(["foo.svg"]); | ||
}, "Two arguments should be passed in, files and an output file name"); | ||
test.done(); | ||
}, | ||
twoargs: function( test ){ | ||
test.expect(8); | ||
var output = "testfile.css"; | ||
var de = new Constructor( ["foo.svg", "bar.svg"], output ); | ||
test.equal( de.output, output, "Output should be set" ); | ||
test.equal( de.files[0], "foo.svg", "First file should match foo.svg" ); | ||
test.equal( de.files[1], "bar.svg", "First file should match foo.svg" ); | ||
test.equal( de.prefix, ".icon-", "Default prefix is .icon-" ); | ||
test.equal( Object.keys(de.customselectors).length, 0, "Default custom selectors is empty object" ); | ||
test.deepEqual( de.template, false, "Default value for a template is false" ); | ||
test.deepEqual( de.templatePrepend, "", "Default value for templatePrepend is empty string" ); | ||
test.deepEqual( de.templateAppend, "", "Default value for templateAppend is empty string" ); | ||
test.done(); | ||
}, | ||
options: function( test ){ | ||
test.expect(6); | ||
var output = "testfile.css"; | ||
var options = { | ||
prefix: "foo", | ||
templatePrepend: "baa", | ||
templateAppend: "ram" | ||
}; | ||
var de = new Constructor( ["foo.svg", "bar.svg"], output, options ); | ||
test.equal( de.output, output, "Output should be set" ); | ||
test.equal( de.files[0], "foo.svg", "First file should match foo.svg" ); | ||
test.equal( de.files[1], "bar.svg", "First file should match foo.svg" ); | ||
test.equal( de.prefix, "foo", "Default prefix is .icon-" ); | ||
test.deepEqual( de.templatePrepend, "baa", "Default value for templatePrepend is empty string" ); | ||
test.deepEqual( de.templateAppend, "ram", "Default value for templateAppend is empty string" ); | ||
test.done(); | ||
} | ||
}; | ||
exports.encode = { | ||
setUp: function( done ) { | ||
@@ -219,3 +280,3 @@ this.encoder = new Constructor( "test/directory-files", output ); | ||
setUp: function( done ){ | ||
this.encoder = new Constructor( "test/directory-files", "test/output/encode.css", | ||
this.encoder = new Constructor( ["test/directory-files/bear.svg", "test/directory-files/dog.png"], "test/output/encode.css", | ||
{ | ||
@@ -229,3 +290,3 @@ template: path.resolve( "test/files/default-css.hbs" ), | ||
} ); | ||
this.encoder2 = new Constructor( "test/directory-files", "test/output/encode2.css", | ||
this.encoder2 = new Constructor( ["test/directory-files/bear.svg", "test/directory-files/dog.png"], "test/output/encode2.css", | ||
{ | ||
@@ -232,0 +293,0 @@ template: path.resolve( "test/files/default-css.hbs" ), |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40021
21
720
71