Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

datauri

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datauri - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

bin/datauri

84

datauri.js

@@ -1,83 +0,1 @@

#!/usr/bin/env node
/*
* datauri - A simple Data URI scheme generator
* https://github.com/heldr/datauri
*
* Copyright (c) 2012 Helder Santana
* Licensed under the MIT license.
* https://raw.github.com/heldr/datauri/master/MIT-LICENSE.txt
*/
var args = process.argv,
fs = require('fs'),
path = require('path'),
mime = require('./lib/mime'),
uri = require('./lib/uri'),
css = require('./lib/css');
function writeNewCssFile( file , content , action ) {
fs.writeFile( file , content , 'utf-8' , function(err) {
if(err) {
throw err;
}
console.log('File ' + action + ': ' + file);
});
}
function outputCSS( file , content ) {
content = css({
className: args[4] || path.basename( file , path.extname(file) ),
background: content
});
if ( fs.existsSync(file) ) {
if ( path.extname(file).match(/(css|sass|less)/) ) {
fs.readFile( file , 'utf-8' , function( err , cssContent ) {
cssContent += content;
writeNewCssFile( file , cssContent , 'updated' );
});
} else {
console.log( 'Must be a CSS file' );
}
} else {
writeNewCssFile( file , content , 'created' );
}
}
if (args.length > 2) {
var fileName = args[2];
if ( fs.existsSync( fileName ) ) {
fs.readFile( fileName , 'base64' , function( err , content ) {
if(err) {
throw err;
}
try {
content = uri({
mimetype: mime.getFromFile( fileName ),
base64: content
});
( args.length < 4 ) ? console.log( content ) : outputCSS( args[3] , content );
} catch(err) {
throw err;
}
});
}
}
module.exports = require('./lib/exec');

@@ -10,3 +10,3 @@ /*

var _ = require('underscore');
var _ = require('lodash');

@@ -13,0 +13,0 @@ var template = [

@@ -10,3 +10,3 @@ /*

var _ = require('underscore');
var _ = require('lodash');

@@ -13,0 +13,0 @@ var template = "data:<%= mimetype %>;base64,<%= base64 %>";

{
"name": "datauri",
"version": "0.0.1",
"version": "0.1.0",
"description": "A simple Data URI scheme generator",
"main": "datauri.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "make test"
},
"dependencies": {
"underscore":"latest"
"lodash": "*"
},

@@ -17,6 +17,6 @@ "repository": {

"engines": {
"node": ">=0.6.0"
"node": ">= 0.8"
},
"bin": {
"datauri": "./datauri.js"
"datauri": "./bin/datauri"
},

@@ -32,3 +32,6 @@ "preferGlobal": true,

"author": "Helder Santana",
"license": "MIT"
"license": "MIT",
"devDependencies": {
"jshint": "~0.9.1"
}
}
datauri
=======
A simple Data URI scheme generator
A simple [Data URI scheme][datauri] generator built on top of [Node.js][nodejs]. To install datauri, just run:
`npm install -g datauri` (it may require Root privileges)
HOW TO USE
----------
### Print datauri scheme
To print a datauri scheme from a file
```CLI
$ datauri brand.png
```
### CSS Background
You can generate or update an output css file with datauri background:
```CLI
$ datauri brand.png asset/background.css
```
If you want to define a Class Name, just type:
```CLI
$ datauri brand.png asset/background.css MyNewClass
```
[nodejs]: http://nodejs.org/download
[datauri]: http://en.wikipedia.org/wiki/Data_URI_scheme

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