Skip to content

Instantly share code, notes, and snippets.

@ZeroDragon
Created April 7, 2016 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZeroDragon/14117b15d1517451894c3d5d819f35f3 to your computer and use it in GitHub Desktop.
Save ZeroDragon/14117b15d1517451894c3d5d819f35f3 to your computer and use it in GitHub Desktop.
ChaiTea Plugins

First plugin test...

require 'chaitea-framework'
require './plugins'
###*
* Console With Time
###
df = "yyyy/mm/dd HH:MM:ss"
util = require 'util'
logger = (arg)-> process.stdout.write(arg)
printer = (type,logs)->
d = ~~(new Date().getTime()/1000)
addZ = (i)-> ('00'+i).slice(-2)
t = "[#{CT_DateFormat(d,df)}]"[type]
if logs.length is 1
te = logs[0]
if typeof(logs[0]) is 'object'
te = util.inspect(logs[0])
te = te
logger "#{t} #{te}\n"
else
logs = logs.map (e)->
if typeof(e) is 'object'
return util.inspect(e)
else
return e
logger "#{t} #{logs.join(' ')}\n"
console.log = (logs...)-> printer 'blue',logs
console.error = (logs...)-> printer 'red',logs
console.warn = (logs...)-> printer 'yellow',logs
p = require("path")
normalizedPath = p.join(__dirname)
require('fs').readdirSync(normalizedPath).forEach (file) ->
if file isnt 'index.coffee'
require p.join(normalizedPath,file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment