[Pkg-javascript-commits] [node-log-driver] 11/49: set up test framework, travis-ci, coveralls.io.
Bastien Roucariès
rouca at moszumanska.debian.org
Thu Feb 22 12:57:01 UTC 2018
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-log-driver.
commit 8ec7426cd43632deb1e5cc108ab86184b6dec2f8
Author: cainus <gregg at caines.ca>
Date: Mon Mar 25 14:31:02 2013 -0700
set up test framework, travis-ci, coveralls.io.
---
.gitignore | 17 +++------------
.travis.yml | 3 +++
Makefile | 17 +++++++++++++++
index.js | 54 +++++-------------------------------------------
index.js => lib/index.js | 0
5 files changed, 28 insertions(+), 63 deletions(-)
diff --git a/.gitignore b/.gitignore
index a57a19f..e4079fc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,15 +1,4 @@
-lib-cov
-*.seed
-*.log
-*.csv
-*.dat
-*.out
-*.pid
-*.gz
-
-pids
-logs
-results
-
+node_modules
npm-debug.log
-node_modules/
+lib-cov
+coverage.html
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..baa0031
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,3 @@
+language: node_js
+node_js:
+ - 0.8
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..d1e5302
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,17 @@
+REPORTER = spec
+test:
+ @NODE_ENV=test ./node_modules/.bin/mocha -b --reporter $(REPORTER)
+
+lib-cov:
+ jscoverage lib lib-cov
+
+test-cov: lib-cov
+ @LOGDRIVER_COVERAGE=1 $(MAKE) test REPORTER=html-cov > coverage.html
+ rm -rf lib-cov
+
+test-coveralls: lib-cov
+ echo TRAVIS_JOB_ID $(TRAVIS_JOB_ID)
+ @LOGDRIVER_COVERAGE=1 $(MAKE) test REPORTER=json-cov 2> /dev/null | ./node_modules/coveralls/bin/coveralls.js
+ rm -rf lib-cov
+
+.PHONY: test
diff --git a/index.js b/index.js
index 8838581..39c829d 100644
--- a/index.js
+++ b/index.js
@@ -1,51 +1,7 @@
-var util = require('util');
+var dir = './lib/';
+if (process.env.LOGDRIVER_COVERAGE){
+ dir = './lib-cov/';
+}
-LogDriver = function(options){
- options = options || {};
- var logger = this;
- if (options.format){
- this.format = options.format;
- }
- this.levels = options.levels || ['error', 'warn', 'info', 'debug', 'trace'];
- this.level = options.level || this.levels[this.levels.length - 1];
- if (this.levels.indexOf(this.level) === -1){
- throw new Error("Log level '" +
- this.level +
- "' does not exist in level list '" + JSON.stringify() + "'");
- }
- this.levels.forEach(function(level){
- if (logger.levels.indexOf(level) <= logger.levels.indexOf(logger.level)){
- logger[level] = function(){
- var args = Array.prototype.slice.call(arguments);
- args.unshift(level); // log level is added as the first parameter
- console.log(logger.format.apply(logger, args));
- };
- } else {
- logger[level] = function(){/* no-op, because this log level is ignored */};
- }
- });
-};
+module.exports = require(dir + 'index');
-LogDriver.prototype.format = function(){
- var args = Array.prototype.slice.call(arguments, [1]); // change arguments to an array, but
- // drop the first item (log level)
- var out = "[" + arguments[0] + "] " + JSON.stringify(new Date()) + " ";
- args.forEach(function(arg){
- out += " " + util.inspect(arg);
- });
- return out;
-};
-
-logger = function(options){
- logger.logger = new LogDriver(options);
- return logger.logger;
-};
-
-module.exports = logger();
-
-/*
-var l = logger({"level" : "info"}); //, format : function(){return JSON.stringify(arguments);}});
-l.error("something went horribly wrong");
-l.info("FYI", {asdf:true});
-l.debug("debug", {show:false});
-*/
diff --git a/index.js b/lib/index.js
similarity index 100%
copy from index.js
copy to lib/index.js
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-log-driver.git
More information about the Pkg-javascript-commits
mailing list