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

nodeutil

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodeutil - npm Package Compare versions

Comparing version 0.0.14 to 0.0.16

lib/git/json-to-table.js

17

lib/cfgutil.js
var fs = require('fs')
, request = require('request')
, Step = require('./git/step')
, log = require('./logger').getInstance();

@@ -17,3 +19,16 @@

}
exports.readJsonCfg = readJsonCfg;
exports.readJsonCfg = readJsonCfg;
function readJsonCfgFromUrl(url, opts, fn){
opts.url = url;
var result = null;
var start = new Date().getTime()
, ts = 0;
request(opts, function(e,r,d){
result = d;
ts = new Date().getTime() - start;
return fn(result);
});
}
exports.readJsonCfgFromUrl = readJsonCfgFromUrl;

@@ -10,2 +10,6 @@ var exports = module.exports;

exports.sqlutil = require('./sqlutil');
exports.xml2json = require('./git/xml2json');
//From: https://github.com/buglabs/node-xml2json
//Modify the trim function for break line parse
exports.json2table = require('./git/json-to-table');

@@ -12,0 +16,0 @@ String.prototype.endsWith = function (s) {

87

lib/mailutil.js

@@ -1,9 +0,25 @@

var nodemailer = require("nodemailer");
var os = require('os');
var fs = require('fs');
var util = require('util');
var cfg = null;
var nodemailer = require("nodemailer")
, log = require('./logger').getInstance()
, os = require('os')
, fs = require('fs')
, cfg = null
, smtpOption = {}
, smtpTransport = null
, cfg_path = process.env.HOME + '/.nmail';
var mailutil = exports;
exports.init = function(json){
if(json) {
log.debug('Setting the cfg using json...' );
log.debug(json);
cfg = json;
log.debug('Confirm cfg:');
log.debug(cfg);
smtpOption = json.smtpOptions;
}
initial();
}
/* node.js v0.6.x still no fs.existsSync() */

@@ -17,33 +33,34 @@ function isCfgExists() {

}
//node 0.8.x
//return fs.existsSync(cfg_path);
}
var cfg_path = process.env.HOME + '/.nmail';
if(isCfgExists()) {
cfg = require('../lib/cfgutil').readJsonCfg(process.env.HOME + '/.nmail');
} else {
cfg = {smtpOptions:{host : "localhost"}};
}
var smtpOption = cfg.smtpOptions;
mailutil.smtpOption = smtpOption;
function initial(){
if(!cfg || cfg == null)
if(isCfgExists()) {
cfg = require('../lib/cfgutil').readJsonCfg(process.env.HOME + '/.nmail');
} else {
cfg = {smtpOptions:{host : "localhost"}};
}
smtpOption = cfg.smtpOptions;
smtpTransport = nodemailer.createTransport("SMTP", smtpOption);
mailutil.smtpOption = smtpOption;
/**
* SMTP transport object
*/
var smtpTransport = nodemailer.createTransport("SMTP", smtpOption);
/**
* SMTP transport object
*/
smtpTransport = nodemailer.createTransport("SMTP", smtpOption);
/**
* To set the SMTP transport using option
*/
mailutil.setSmtpTransUsingOption = function(opt){
smtpTransport = nodemailer.createTransport("SMTP", opt);
};
/**
* To set the SMTP transport using option
*/
mailutil.setSmtpTransUsingOption = function(opt){
smtpTransport = nodemailer.createTransport("SMTP", opt);
};
/**
* To reset the SMTP transport using the last smtpOption
*/
mailutil.resetSmtpTrans = function() {
smtpTransport = nodemailer.createTransport("SMTP", this.smtpOption);
};
/**
* To reset the SMTP transport using the last smtpOption
*/
mailutil.resetSmtpTrans = function() {
smtpTransport = nodemailer.createTransport("SMTP", this.smtpOption);
};
}

@@ -73,9 +90,9 @@ /**

mailOptions.html = msg;
util.log(util.format('[INFO]Using smtpOption:%s', JSON.stringify(smtpOption)));
util.log(util.format('[INFO]Using mailOptions:%s', JSON.stringify(mailOptions)));
log.debug('[INFO]Using smtpOption:%s', JSON.stringify(smtpOption));
log.debug('[INFO]Using mailOptions:%s', JSON.stringify(mailOptions));
smtpTransport.sendMail(mailOptions, function(error, response){
if(error){
console.log('[ERROR]%s',JSON.stringify(error));
log.error('[ERROR]%s',JSON.stringify(error));
} else {
util.log(util.format("Message sent: " + response.message));
log.debug("Message sent: " + response.message);
}

@@ -82,0 +99,0 @@ if(isClose)

{
"name": "nodeutil",
"description": "Node.js Utility",
"version": "0.0.14",
"version": "0.0.16",
"author": {

@@ -17,2 +17,4 @@ "name": "Simon Su",

"nodemailer": "*",
"node-expat": "*",
"request": "*",
"log4js": "*"

@@ -37,3 +39,3 @@ },

},
"_id": "nodeutil@0.0.1",
"_id": "nodeutil@0.0.16",
"optionalDependencies": {},

@@ -40,0 +42,0 @@ "_engineSupported": true,

NodeUtil
====================
<h2>Usage</h2>
This is just a tool collect for easy use of some tool library. I will pack some operation for more easy to use.
## Install
<pre>
npm install nodeutil
</pre>
## Usage
<pre>
var nu = require('nodeutil');
</pre>
//Using logger
## Using logger
<pre>
var log = nu.logger.getInstance();
log.info('Test logger...');
</pre>
//Using dateutil
## Using dateutil
<pre>
var dateutil = no.dateutil;

@@ -18,4 +32,7 @@ var pattern = 'yyyymmdd hh24:mi:ss';

dateutil.getDateString(new Date(), pattern)
</pre>
//Using step
## Using step
<pre>
var Step = nu.step;

@@ -33,4 +50,10 @@ Step(

)
</pre>
## Using cfgutil
<pre>
var cfgutil = nu.cfgutil;
//read from json file
var cfg = cfgutil.readJsonCfg('path to json config file');
</pre>
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