Create a gist now

Instantly share code, notes, and snippets.

@dbankier /
Last active Dec 14, 2015

What would you like to do?
alloy.jmk for Alloy use with TiShadow

It enables you to free memory between launching TiShadow builds.

Updated based on @FokkeZB's improvements

task("post:compile", function(event,logger) {
var fs = require("fs"),
path = require("path");
if (event.alloyConfig.deployType === 'production') {
var existing_bits = 'Alloy.createController("index");'
var tishadow_bits =
[ 'var index = Alloy.createController("index");',
'if (typeof exports !== "undefined") {',
' exports.close = function () {',
' index.getView().close();',
' };',
var appjs = path.join(event.dir.resources, "app.js");
fs.readFileSync(appjs).toString().replace(existing_bits, tishadow_bits));
//Example app/controllers/index.js
$.index.addEventListener('close',function() {
// Add other cleanup bits hear if necessary
FokkeZB commented May 22, 2013

I've posted an improved version of the code at:


@FokkeZB, updated based on your improvements. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment