Socket
Socket
Sign inDemoInstall

directory-encoder

Package Overview
Dependencies
Maintainers
3
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

directory-encoder - npm Package Compare versions

Comparing version 0.8.1 to 0.9.0

test/files/custom-hbs-helper.hbs

2

lib/directory-encoder.js

@@ -35,2 +35,3 @@ /*global require:true*/

this.options.pngpath = this.options.pngpath || this.options.pngfolder;
this.options.handlebarsCallback = this.options.handlebarsCallback || function () {};

@@ -178,2 +179,3 @@ this.customselectors = this.options.customselectors || {};

var source = fs.readFileSync( templateFile ).toString( 'utf-8' );
this.options.handlebarsCallback(Handlebars);
tmpl = Handlebars.compile(source);

@@ -180,0 +182,0 @@ } else {

4

package.json
{
"name": "directory-encoder",
"description": "Encode a directory of images to CSS",
"version": "0.8.1",
"version": "0.9.0",
"homepage": "https://github.com/filamentgroup/directory-encoder",

@@ -27,3 +27,3 @@ "author": {

"fs-extra": "^0.23.1",
"handlebars": "^1.3.0",
"handlebars": "^4.0.0",
"img-stats": "^0.5.2"

@@ -30,0 +30,0 @@ },

@@ -18,2 +18,3 @@ # directory-encoder [![Build Status](https://secure.travis-ci.org/filamentgroup/directory-encoder.png?branch=master)](http://travis-ci.org/filamentgroup/directory-encoder)

templatePrepend: "/* start of icon-list */", // this string is prepended to the destinationCSSFile, defaults to ""
handlebarsCallback: function(hbs) { /* configure handlebars, with custom helpers for example */ }, // callback to configure handlebars
template: template.hbs, //template in handlebars, FANCY!

@@ -20,0 +21,0 @@ templateAppend: "/* end of icon-list */", // this string is appended to the destinationCSSFile, defaults to ""

@@ -10,4 +10,4 @@ /*global require:true*/

var outputFileData = '\n.icon-2,\n\n.what-bear {\n\tbackground-image: url(\'data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22100%22%20height%3D%2262.905px%22%3E%3Cpath%20d%3D%22M11.068%2C34.558c-1.585-2.365-2.595-5.098-2.939-8.106c-0.344%2C0.092-0.666%2C0.161-1.033%2C0.161%20c-2.342%2C0-4.248-1.906-4.248-4.248c0-1.47%2C0.758-2.756%2C1.883-3.514l12.147-8.45c2.549-1.562%2C5.534-2.526%2C8.749-2.641l30.149%2C0.092%20L77.819%2C4.34c0-0.115%2C0-0.229%2C0-0.345C77.819%2C1.791%2C79.586%2C0%2C81.791%2C0c2.205%2C0%2C3.996%2C1.791%2C3.996%2C3.995%20c0%2C0.345-0.046%2C0.712-0.138%2C1.034l2.043%2C0.275c2.365%2C0.459%2C4.156%2C2.549%2C4.156%2C5.052c0%2C0.161%2C0%2C0.298-0.022%2C0.436l6.544%2C3.536%20c0.941%2C0.368%2C1.63%2C1.309%2C1.63%2C2.388c0%2C0.367-0.068%2C0.689-0.206%2C1.01l-1.631%2C3.697c-0.804%2C1.309-2.181%2C2.228-3.788%2C2.411%20l-15.041%2C1.791L65.787%2C41.527l7.738%2C13.363l5.098%2C2.365c0.803%2C0.552%2C1.354%2C1.493%2C1.354%2C2.549c0%2C1.699-1.378%2C3.078-3.101%2C3.078%20l-9.805%2C0.022c-2.525%2C0-4.707-1.424-5.809-3.49l-8.382-15.155l-18.92%2C0.023l6.682%2C10.287l4.937%2C2.25%20c0.919%2C0.551%2C1.516%2C1.538%2C1.516%2C2.664c0%2C1.699-1.378%2C3.076-3.077%2C3.076l-9.828%2C0.023c-2.388%2C0-4.5-1.286-5.649-3.215l-9.208-14.627%20l-6.429%2C6.246l-0.528%2C4.087l2.158%2C1.423c0.368%2C0.184%2C0.689%2C0.438%2C0.965%2C0.758c1.056%2C1.332%2C0.872%2C3.284-0.459%2C4.34%20c-0.574%2C0.482-1.286%2C0.713-1.975%2C0.689l-4.317%2C0.023c-1.194-0.139-2.273-0.758-2.962-1.677l-5.029-8.68C0.275%2C51.033%2C0%2C50%2C0%2C48.898%20c0-1.676%2C0.62-3.215%2C1.676-4.387L11.068%2C34.558z%22%2F%3E%3C%2Fsvg%3E\');\n\tbackground-repeat: no-repeat;\n\twidth: 100px;\n\theight: 62.905px;\n}\n\n\n\n.what-dog {\n\tbackground-image: url(\'dog.png\');\n\tbackground-repeat: no-repeat;\n\twidth: 100px;\n\theight: 62.905px;\n}\n\n\n';
var outputFileData2 = '\n.icon-2,\n\n.icon-bear:before,\n\n.icon-bear:after,\n\n.what-bear {\n\tbackground-image: url(\'data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22100%22%20height%3D%2262.905px%22%3E%3Cpath%20d%3D%22M11.068%2C34.558c-1.585-2.365-2.595-5.098-2.939-8.106c-0.344%2C0.092-0.666%2C0.161-1.033%2C0.161%20c-2.342%2C0-4.248-1.906-4.248-4.248c0-1.47%2C0.758-2.756%2C1.883-3.514l12.147-8.45c2.549-1.562%2C5.534-2.526%2C8.749-2.641l30.149%2C0.092%20L77.819%2C4.34c0-0.115%2C0-0.229%2C0-0.345C77.819%2C1.791%2C79.586%2C0%2C81.791%2C0c2.205%2C0%2C3.996%2C1.791%2C3.996%2C3.995%20c0%2C0.345-0.046%2C0.712-0.138%2C1.034l2.043%2C0.275c2.365%2C0.459%2C4.156%2C2.549%2C4.156%2C5.052c0%2C0.161%2C0%2C0.298-0.022%2C0.436l6.544%2C3.536%20c0.941%2C0.368%2C1.63%2C1.309%2C1.63%2C2.388c0%2C0.367-0.068%2C0.689-0.206%2C1.01l-1.631%2C3.697c-0.804%2C1.309-2.181%2C2.228-3.788%2C2.411%20l-15.041%2C1.791L65.787%2C41.527l7.738%2C13.363l5.098%2C2.365c0.803%2C0.552%2C1.354%2C1.493%2C1.354%2C2.549c0%2C1.699-1.378%2C3.078-3.101%2C3.078%20l-9.805%2C0.022c-2.525%2C0-4.707-1.424-5.809-3.49l-8.382-15.155l-18.92%2C0.023l6.682%2C10.287l4.937%2C2.25%20c0.919%2C0.551%2C1.516%2C1.538%2C1.516%2C2.664c0%2C1.699-1.378%2C3.076-3.077%2C3.076l-9.828%2C0.023c-2.388%2C0-4.5-1.286-5.649-3.215l-9.208-14.627%20l-6.429%2C6.246l-0.528%2C4.087l2.158%2C1.423c0.368%2C0.184%2C0.689%2C0.438%2C0.965%2C0.758c1.056%2C1.332%2C0.872%2C3.284-0.459%2C4.34%20c-0.574%2C0.482-1.286%2C0.713-1.975%2C0.689l-4.317%2C0.023c-1.194-0.139-2.273-0.758-2.962-1.677l-5.029-8.68C0.275%2C51.033%2C0%2C50%2C0%2C48.898%20c0-1.676%2C0.62-3.215%2C1.676-4.387L11.068%2C34.558z%22%2F%3E%3C%2Fsvg%3E\');\n\tbackground-repeat: no-repeat;\n\twidth: 100px;\n\theight: 62.905px;\n}\n\n\n\n.icon-dog:before,\n\n.icon-dog:after,\n\n.what-dog {\n\tbackground-image: url(\'dog.png\');\n\tbackground-repeat: no-repeat;\n\twidth: 100px;\n\theight: 62.905px;\n}\n\n\n';
var outputFileData = '.icon-2,\n.what-bear {\n\tbackground-image: url(\'data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22100%22%20height%3D%2262.905px%22%3E%3Cpath%20d%3D%22M11.068%2C34.558c-1.585-2.365-2.595-5.098-2.939-8.106c-0.344%2C0.092-0.666%2C0.161-1.033%2C0.161%20c-2.342%2C0-4.248-1.906-4.248-4.248c0-1.47%2C0.758-2.756%2C1.883-3.514l12.147-8.45c2.549-1.562%2C5.534-2.526%2C8.749-2.641l30.149%2C0.092%20L77.819%2C4.34c0-0.115%2C0-0.229%2C0-0.345C77.819%2C1.791%2C79.586%2C0%2C81.791%2C0c2.205%2C0%2C3.996%2C1.791%2C3.996%2C3.995%20c0%2C0.345-0.046%2C0.712-0.138%2C1.034l2.043%2C0.275c2.365%2C0.459%2C4.156%2C2.549%2C4.156%2C5.052c0%2C0.161%2C0%2C0.298-0.022%2C0.436l6.544%2C3.536%20c0.941%2C0.368%2C1.63%2C1.309%2C1.63%2C2.388c0%2C0.367-0.068%2C0.689-0.206%2C1.01l-1.631%2C3.697c-0.804%2C1.309-2.181%2C2.228-3.788%2C2.411%20l-15.041%2C1.791L65.787%2C41.527l7.738%2C13.363l5.098%2C2.365c0.803%2C0.552%2C1.354%2C1.493%2C1.354%2C2.549c0%2C1.699-1.378%2C3.078-3.101%2C3.078%20l-9.805%2C0.022c-2.525%2C0-4.707-1.424-5.809-3.49l-8.382-15.155l-18.92%2C0.023l6.682%2C10.287l4.937%2C2.25%20c0.919%2C0.551%2C1.516%2C1.538%2C1.516%2C2.664c0%2C1.699-1.378%2C3.076-3.077%2C3.076l-9.828%2C0.023c-2.388%2C0-4.5-1.286-5.649-3.215l-9.208-14.627%20l-6.429%2C6.246l-0.528%2C4.087l2.158%2C1.423c0.368%2C0.184%2C0.689%2C0.438%2C0.965%2C0.758c1.056%2C1.332%2C0.872%2C3.284-0.459%2C4.34%20c-0.574%2C0.482-1.286%2C0.713-1.975%2C0.689l-4.317%2C0.023c-1.194-0.139-2.273-0.758-2.962-1.677l-5.029-8.68C0.275%2C51.033%2C0%2C50%2C0%2C48.898%20c0-1.676%2C0.62-3.215%2C1.676-4.387L11.068%2C34.558z%22%2F%3E%3C%2Fsvg%3E\');\n\tbackground-repeat: no-repeat;\n\twidth: 100px;\n\theight: 62.905px;\n}\n\n\n.what-dog {\n\tbackground-image: url(\'dog.png\');\n\tbackground-repeat: no-repeat;\n\twidth: 100px;\n\theight: 62.905px;\n}\n\n\n';
var outputFileData2 = '.icon-2,\n.icon-bear:before,\n.icon-bear:after,\n.what-bear {\n\tbackground-image: url(\'data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22100%22%20height%3D%2262.905px%22%3E%3Cpath%20d%3D%22M11.068%2C34.558c-1.585-2.365-2.595-5.098-2.939-8.106c-0.344%2C0.092-0.666%2C0.161-1.033%2C0.161%20c-2.342%2C0-4.248-1.906-4.248-4.248c0-1.47%2C0.758-2.756%2C1.883-3.514l12.147-8.45c2.549-1.562%2C5.534-2.526%2C8.749-2.641l30.149%2C0.092%20L77.819%2C4.34c0-0.115%2C0-0.229%2C0-0.345C77.819%2C1.791%2C79.586%2C0%2C81.791%2C0c2.205%2C0%2C3.996%2C1.791%2C3.996%2C3.995%20c0%2C0.345-0.046%2C0.712-0.138%2C1.034l2.043%2C0.275c2.365%2C0.459%2C4.156%2C2.549%2C4.156%2C5.052c0%2C0.161%2C0%2C0.298-0.022%2C0.436l6.544%2C3.536%20c0.941%2C0.368%2C1.63%2C1.309%2C1.63%2C2.388c0%2C0.367-0.068%2C0.689-0.206%2C1.01l-1.631%2C3.697c-0.804%2C1.309-2.181%2C2.228-3.788%2C2.411%20l-15.041%2C1.791L65.787%2C41.527l7.738%2C13.363l5.098%2C2.365c0.803%2C0.552%2C1.354%2C1.493%2C1.354%2C2.549c0%2C1.699-1.378%2C3.078-3.101%2C3.078%20l-9.805%2C0.022c-2.525%2C0-4.707-1.424-5.809-3.49l-8.382-15.155l-18.92%2C0.023l6.682%2C10.287l4.937%2C2.25%20c0.919%2C0.551%2C1.516%2C1.538%2C1.516%2C2.664c0%2C1.699-1.378%2C3.076-3.077%2C3.076l-9.828%2C0.023c-2.388%2C0-4.5-1.286-5.649-3.215l-9.208-14.627%20l-6.429%2C6.246l-0.528%2C4.087l2.158%2C1.423c0.368%2C0.184%2C0.689%2C0.438%2C0.965%2C0.758c1.056%2C1.332%2C0.872%2C3.284-0.459%2C4.34%20c-0.574%2C0.482-1.286%2C0.713-1.975%2C0.689l-4.317%2C0.023c-1.194-0.139-2.273-0.758-2.962-1.677l-5.029-8.68C0.275%2C51.033%2C0%2C50%2C0%2C48.898%20c0-1.676%2C0.62-3.215%2C1.676-4.387L11.068%2C34.558z%22%2F%3E%3C%2Fsvg%3E\');\n\tbackground-repeat: no-repeat;\n\twidth: 100px;\n\theight: 62.905px;\n}\n\n\n.icon-dog:before,\n.icon-dog:after,\n.what-dog {\n\tbackground-image: url(\'dog.png\');\n\tbackground-repeat: no-repeat;\n\twidth: 100px;\n\theight: 62.905px;\n}\n\n\n';
var encoder, output = path.resolve( path.join( __dirname, "output", "encoded.css" ) );

@@ -224,3 +224,3 @@

test.equal( this.encoder2._css("foo", "bar"),
"\n.icon-foo {\n" +
".icon-foo {\n" +
"\tbackground-image: url('bar');\n" +

@@ -234,4 +234,4 @@ "\tbackground-repeat: no-repeat;\n" +

test.equal( this.encoder3._css("foo", "bar"),
"\n.icon-2,\n" +
"\n.icon-foo {\n" +
".icon-2,\n" +
".icon-foo {\n" +
"\tbackground-image: url('bar');\n" +

@@ -245,4 +245,4 @@ "\tbackground-repeat: no-repeat;\n" +

test.equal( this.encoder4._css("foo", "bar"),
"\n.icon-2,\n" +
"\n.what-foo {\n" +
".icon-2,\n" +
".what-foo {\n" +
"\tbackground-image: url('bar');\n" +

@@ -256,7 +256,7 @@ "\tbackground-repeat: no-repeat;\n" +

test.equal( this.encoder5._css("foo", "bar"),
"\n.icon-2,\n" +
"\n.icon-foo:before,\n" +
"\n.icon-foo-what,\n" +
"\n.hey-foo,\n" +
"\n.icon-foo {\n" +
".icon-2,\n" +
".icon-foo:before,\n" +
".icon-foo-what,\n" +
".hey-foo,\n" +
".icon-foo {\n" +
"\tbackground-image: url('bar');\n" +

@@ -303,6 +303,30 @@ "\tbackground-repeat: no-repeat;\n" +

} );
// set up for custom HBS helper tests
this.helperFnCalled = false;
this.hbsCallbackCalled = false;
this.helperFn = function(n1, n2) {
this.helperFnCalled = true;
return (n1 + n2).toString();
};
this.hbsCallback = function (hbs) {
this.hbsCallbackCalled = true;
hbs.registerHelper('add', this.helperFn.bind(this));
};
this.encoder3 = new Constructor( ["test/directory-files/bear.svg"], "test/output/encode3.css",
{
template: path.resolve( "test/files/custom-hbs-helper.hbs" ),
handlebarsCallback: this.hbsCallback.bind(this)
} );
done();
},
tearDown: function( done ){
["", "2"].forEach(function( i ){
this.helperFnCalled = false;
this.hbsCallbackCalled = false;
["", "2", "3"].forEach(function( i ){
if( fs.existsSync( "test/output/encode" + i + ".css" ) ){

@@ -333,2 +357,18 @@ fs.unlinkSync( "test/output/encode" + i + ".css" );

test.done();
},
'withHandlebarsCallback': function (test)
{
test.expect( 4 );
this.encoder3.encode();
test.ok( this.hbsCallbackCalled, "Handlebars callback should be called" );
test.ok( this.helperFnCalled, "Handlebars helper should be called" );
test.ok( fs.existsSync( "test/output/encode3.css" ) , "CSS file exists" );
var data = fs.readFileSync( "test/output/encode3.css" ).toString( 'utf-8' );
test.ok( /^3/.test(data), "Encoded file matches" );
test.done();
}

@@ -335,0 +375,0 @@ };

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc