gulp-livescript
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -0,1 +1,9 @@ | ||
## 1.1.0 (2014-09-23) | ||
#### Features | ||
* **index:** add support for outputing json ([306da937](https://github.com/tomchentw/gulp-livescript/commit/306da9373568cf52fe48ca1c2777f03caa573417)) | ||
### 1.0.3 (2014-06-18) | ||
@@ -2,0 +10,0 @@ |
30
index.js
@@ -8,3 +8,3 @@ var through2, LiveScript, gutil; | ||
function modifyLS(file, enc, done){ | ||
var error, ref$; | ||
var error, input, t, json; | ||
if (file.isNull()) { | ||
@@ -17,3 +17,22 @@ return done(null, file); | ||
try { | ||
file.contents = new Buffer(LiveScript.compile(file.contents.toString('utf8'), (ref$ = {}, import$(ref$, options), ref$.filename = file.path, ref$))); | ||
input = file.contents.toString('utf8'); | ||
t = { | ||
input: input, | ||
options: options | ||
}; | ||
json = options.json; | ||
t.tokens = LiveScript.tokens(t.input, { | ||
raw: options.lex | ||
}); | ||
t.ast = LiveScript.ast(t.tokens); | ||
options.bare || (options.bare = json); | ||
if (json) { | ||
t.ast.makeReturn(); | ||
} | ||
t.output = t.ast.compileRoot(options); | ||
if (json) { | ||
t.result = LiveScript.run(t.output, options, true); | ||
t.output = JSON.stringify(t.result, null, 2) + '\n'; | ||
} | ||
file.contents = new Buffer(t.output); | ||
file.path = gutil.replaceExtension(file.path, '.js'); | ||
@@ -30,7 +49,2 @@ } catch (e$) { | ||
return through2.obj(modifyLS); | ||
}; | ||
function import$(obj, src){ | ||
var own = {}.hasOwnProperty; | ||
for (var key in src) if (own.call(src, key)) obj[key] = src[key]; | ||
return obj; | ||
} | ||
}; |
{ | ||
"name": "gulp-livescript", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "Compile LiveScript to JavaScript for Gulp", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
10989
46