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
var escope = require('escope'); | |
var esprima = require('esprima'); | |
var estraverse = require('estraverse'); | |
var code = require('./ast'); | |
var ast = code.esprimaAST(); | |
var scopeManager = escope.analyze(ast); | |
var scopes = scopeManager.scopes; | |
// return an array of scopes, in our example we have 2, the global and inside of the function | |
var currentScope = scopeManager.acquire(ast); | |
// return the global scope, the current one |
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
var estraverse = require('estraverse'); | |
var escodegen = require('escodegen'); | |
var ast = require('./ast'); | |
var a = ast.esprimaAST(); | |
// 'function bar(){ var longVariable; console.log("foo", longVariable);}' | |
estraverse.traverse(a, { | |
enter: function (node, parent) { | |
if (node.type == 'Identifier' && node.name == 'longVariable') { | |
console.log(node); | |
node.name = 'b'; |
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
var escodegen = require('escodegen'); | |
var js = escodegen.generate({ | |
"type": "VariableDeclaration", | |
"start": 0, | |
"end": 6, | |
"range": [ | |
0, | |
6 | |
], | |
"declarations": [ |
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
// esprima | |
var ast = esprima.parse("var foo = 'bar';"); | |
// acorn | |
var ast = acorn.parse('var a;', { | |
// collect ranges for each node | |
ranges: true | |
}); |
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
var ast = esprima.parse("var a;"); |
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
<plugin> | |
<groupId>com.github.eirslett</groupId> | |
<artifactId>frontend-maven-plugin</artifactId> | |
<version>0.0.23</version> | |
<configuration> | |
<workingDirectory>src/main/resources/resource</workingDirectory> | |
</configuration> | |
<executions> | |
<execution> | |
<id>install node and npm</id> |
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
less: { | |
development: { | |
options: { | |
compress: false, | |
yuicompress: false, | |
//sourceMap : true, | |
optimization: 1 | |
}, | |
files: { | |
"<%= dirs.css_src %>/tweetpoll.css": "<%= dirs.less_src %>/tweetpoll.less", |
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
intern: { | |
local_browser: { | |
options: { | |
runType: 'runner', | |
config: '<%= dirs.tests %>/intern_local_browser' | |
} | |
}, | |
remote_local: { | |
options: { | |
runType: 'runner', |
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
{ | |
"name": "resources-enme-war", | |
"version": "1.5.2", | |
"homepage": "https://github.com/encuestame/encuestame", | |
"authors": [ | |
"Juan Picado (@jotadeveloper) <[email protected]>" | |
], | |
"license": "APL2", | |
"ignore": [ | |
"**/.*", |
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
var fs = require('fs'); | |
var esprima = require('esprima'); | |
var escodegen = require('escodegen'); | |
var estraverse = require('estraverse'); | |
fs.readFile('test_1.js', 'utf8', function(err, contents) { | |
var ast = esprima.parse(contents); | |
estraverse.replace(ast, { | |
enter : function (node, parent) { | |
if (node.type === 'Property' && node.key.name.indexOf('jota') != -1) { | |
this.remove(); |