Comparing version 0.0.1 to 0.1.0
@@ -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
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
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
9201
12
181
2
28
1
1
2
+ Addedlodash@*
+ Addedlodash@4.17.21(transitive)
- Removedunderscore@latest
- Removedunderscore@1.13.7(transitive)