🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

cate

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cate - npm Package Compare versions

Comparing version
0.0.1
to
0.0.2
+4
-2
package.json
{
"name": "cate",
"version": "0.0.1",
"version": "0.0.2",
"description": "Pretty printer for different file formats",

@@ -33,4 +33,6 @@ "main": "index.js",

"minimist": "~0.2.0",
"pretty-data": "~0.40.0"
"pretty-data": "~0.40.0",
"request": "^2.36.0",
"js-beautify": "^1.5.1"
}
}
var pd = require('pretty-data').pd;
var fs = require('fs');
var request = require('request');
var jsb = require('js-beautify');

@@ -12,14 +14,20 @@ var formats = ['xml', 'json', 'sql', 'css'];

// TODO http request if url
// TODO handle errors properly
var getContent = function(filepath, cb) {
fs.exists(filepath, function(exists) {
if (!exists) {
return cb('Can\'t open file.');
}
if (isURL(filepath)){
request(filepath, function(err, res, content){
if (err) return cb('Can\'t open URL');
cb(content.toString());
});
} else {
fs.exists(filepath, function(exists) {
if (!exists) {
return cb('Can\'t open file.');
}
fs.readFile(filepath, function(err, content) {
cb(content.toString());
fs.readFile(filepath, function(err, content) {
cb(content.toString());
});
});
});
}
};

@@ -32,7 +40,10 @@

var getFormatter = function(format) {
if (formats.indexOf(format) === -1) {
if (formats.indexOf(format) !== -1) {
return pd[format].bind(pd);
} else if (format === 'js'){
return jsb;
} else {
return nop;
}
return pd[format].bind(pd);
};

@@ -48,2 +59,6 @@

var isURL = function(filepath){
return filepath.search(/\w*:\/\//) !== -1;
}
module.exports = prettify;

Sorry, the diff of this file is not supported yet