Last active
September 7, 2015 18:57
-
-
Save TatsuoWatanabe/9928627 to your computer and use it in GitHub Desktop.
Titanium + Alloy + TypeScript1.0RC のコンパイル ref: http://qiita.com/TatsuoWatanabe/items/14e6b8062d64d895e465
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task("pre:compile", function(event,logger) { | |
var wrench = require("wrench"), | |
fs = require("fs"), | |
path = require("path"); | |
var code = [ | |
fs.readFileSync("/usr/local/lib/node_modules/alloy/bin/tsc.js"), // <- path to tsc.js in your environment | |
"module.exports = TypeScript;" | |
].join(""); | |
fs.writeFileSync(process.env.TMPDIR + "tsc.js", code); | |
var TypeScript = require(process.env.TMPDIR + "tsc.js"); | |
fs.unlinkSync(process.env.TMPDIR + "tsc.js"); | |
event.alloyConfig.tsc = []; | |
var batch = new TypeScript.BatchCompiler(TypeScript.IO); | |
wrench.readdirSyncRecursive(event.dir.home).forEach(function(target){ | |
if (target.match(/\.ts$/) && ! target.match(/\.d\.ts$/)) { | |
var filename = path.join(event.dir.home + "/" + target); | |
batch.inputFiles.push(filename); | |
event.alloyConfig.tsc.push(target.replace(/.ts$/, ".js")); | |
} | |
}); | |
batch.batchCompile(); | |
}); | |
task("post:compile",function(event,logger){ | |
var fs = require("fs"); | |
event.alloyConfig.tsc.forEach(function(target){ | |
fs.unlinkSync(event.dir.home + "/" + target); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.inputFiles = this.inputFiles.filter(function(file) { | |
return file.match(/\.ts$/); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment