Skip to content

Commit

Permalink
Starting the dive into the structure of the AST
Browse files Browse the repository at this point in the history
  • Loading branch information
rustedgrail committed Oct 8, 2012
1 parent d7297e8 commit 586207c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/replacer.coffee
Expand Up @@ -4,13 +4,23 @@ acorn = require 'acorn'

filesSeen = {}

getInnerTree = (parsedInput) ->
if parsedInput.type == 'Program'
for statement in parsedInput.body
if statement.expression.type == 'CallExpression' &&
statement.expression.callee.name == 'require'
for value in statement.expression.arguments
console.log value.value

exports.clearFilelist = ->
filesSeen = {}

exports.addFileToList = (file) ->
filesSeen[file] = true

exports.replaceRequires = (input) ->
getInnerTree acorn.parse input

requireRegex = /^\s*require\((.*?)\);/gm
input.replace requireRegex, (match, p1, offset, string) ->
output = []
Expand Down

0 comments on commit 586207c

Please sign in to comment.