 
 # Tools are a JS file that needs to be parsed
 parsedTools = esprima.parse(fs.readFileSync(path.join(inputDir, "tools.js"), { encoding: "utf8" }))
-# TODO: remove references to "this"
-outputObj.tools = parsedToObj(parsedTools.body[0].expression)
+# Replace "this" references with tools 
+outputObj.tools = parsedToObj(parsedTools.body[0].expression, (code) -> code.replace(/this./g, "tools."))
 
 # Create data-URI encoded versions of all assets
 assetMap = JSON.parse(fs.readFileSync(path.join(inputDir, "assets.json"), { encoding: "utf8" }))


# Actions are a JS file that needs to be parsed
parsedActions = esprima.parse(fs.readFileSync(path.join(inputDir, "actions.js"), { encoding: "utf8" }))
# TODO: remove references to "this"
outputObj.actions = parsedToObj(parsedActions.body[0].expression)

# Copy over layout JSON
outputObj.layout = JSON.parse(fs.readFileSync(path.join(inputDir, "layout.json"), { encoding: "utf8" }))


# This object will be written out as JSON at the end 
outputObj = 
  fileVersion: OUTPUT_VERSION
  model: {}
  layout: {}
  actions: {}
