Permalink
Browse files

implement jedi-transpiler-service

  • Loading branch information...
hax committed Jan 16, 2013
1 parent 8c4070c commit bc93344bbeb3cedbeafa69de2d45f5659351f6cb
Showing with 12 additions and 6 deletions.
  1. +1 −2 cli/jedi-transpiler-service
  2. +1 −1 package.json
  3. +10 −3 src/index.js
@@ -1,14 +1,13 @@
#!/usr/bin/env node
-var fs = require('fs'), path = require('path')
var pkg = require('../package.json')
var jedi = require('../src')
var program = require('commander')
program.
version(pkg.version).
- usage('[options] <basedir>')
+ usage('[options] <basedir>').
option('--php', '编译为PHP').
option('--js', '编译为JavaScript').
option('-w, --watch', '当指定文件的内容变化时自动重新编译').
View
@@ -1,6 +1,6 @@
{
"name": "jedi",
- "version": "0.9.12-beta1",
+ "version": "0.9.12-beta2",
"author": "Hax <johnhax@gmail.com>",
"description": "jedi -- a language for Web",
"keywords": ["view", "template", "dsl"],
View
@@ -12,6 +12,8 @@ var transpiler = {
}
var fs = require('fs'), path = require('path')
+var http = require('http'), url = require('url')
+
var util = require('./util')
var Class = require('mmclass').Class
@@ -30,6 +32,7 @@ function parseFile(filename) {
}
function transform(tree, debug) {
+ if (debug === undefined) debug = []
var tree1 = tree
if (debug[0]) util.dir(tree1)
var tree2 = transformer.InstructionsProcessor.match(tree1, 'document')
@@ -86,9 +89,13 @@ function service(options) {
res.writeHead(404)
res.end('file not exist\n')
} else {
- transpile(f, f.replace(/(.jedi)$/, '.php'))
+ var t0 = Date.now()
+ options.lang.forEach(function(lang){
+ transpile(f, f.replace(/\.jedi$/, '.' + lang), lang)
+ })
+ var t1 = Date.now()
res.writeHead(200)
- res.end('compiled ok\n')
+ res.end('transpiled in ' + (t1 - t0) + 'ms\n')
}
})
@@ -102,7 +109,7 @@ function service(options) {
}
-//exports.parseFile = parseFile
+exports.parseFile = parseFile
//exports.transform = transform
//exports.compile = compile
exports.transpile = transpile

0 comments on commit bc93344

Please sign in to comment.