Skip to content

Commit

Permalink
add exitCode
Browse files Browse the repository at this point in the history
  • Loading branch information
Claus Reinke committed Jun 16, 2012
1 parent 3d76dbb commit c883949
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 16 deletions.
15 changes: 11 additions & 4 deletions estr.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ switch (process.argv.shift()) {

console.error("parse error in "+results[0].sourcefile
,results[0].parseError);
exitCode(1);

} else if (results[0].decls){

Expand All @@ -67,6 +68,7 @@ switch (process.argv.shift()) {
} else {

console.error('unknown result',results[0]);
exitCode(1);

}
}
Expand Down Expand Up @@ -112,14 +114,17 @@ switch (process.argv.shift()) {

console.error("parse error in "+results[0].sourcefile
,results[0].parseError);
exitCode(1);

} else if (results[0].error) {

console.error(results[0].error.message);
exitCode(1);

} else {

console.error('unknown result',results[0]);
exitCode(1);

}
}
Expand Down Expand Up @@ -170,14 +175,17 @@ switch (process.argv.shift()) {

console.error("parse error in "+results[0].sourcefile
,results[0].parseError);
exitCode(1);

} else if (results[0].error) {

console.error(results[0].error.message);
exitCode(1);

} else {

console.error('unknown result',results[0]);
exitCode(1);

}
}
Expand Down Expand Up @@ -207,7 +215,6 @@ function processJSfiles(paths,action) {
return results;
}

function updateFile(action) { return function(path,source) {
var newSource = action(path,source);
fs.writeFileSync(path,newSource);
}}
function exitCode(code) {
process.on('exit',function(){process.exit(1)});
}
1 change: 1 addition & 0 deletions tests/.gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ sample-work.js.bak -text
tags -text
*.stdout -text
*.stderr -text
*.error -text
10 changes: 9 additions & 1 deletion tests/out/rename-capture-existing-occurrences.error
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
null
Error: Command failed: WARNING! hoisting var declaration over catch of same name: e
{ start: { line: 20, column: 8 },
end: { line: 20, column: 16 } }
WARNING! hoisting function declaration over catch of same name: f
{ start: { line: 28, column: 4 },
end: { line: 28, column: 24 } }
renamed binding for a would capture
existing occurrences of x
{ line: 36, column: 10 }
10 changes: 9 additions & 1 deletion tests/out/rename-capture-renamed-occurrences.error
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
null
Error: Command failed: WARNING! hoisting var declaration over catch of same name: e
{ start: { line: 20, column: 8 },
end: { line: 20, column: 16 } }
WARNING! hoisting function declaration over catch of same name: f
{ start: { line: 28, column: 4 },
end: { line: 28, column: 24 } }
renamed occurrences of x would be captured
by existing bindings for a
x { line: 36, column: 10 } by a { line: 35, column: 38 } FunctionExpression Parameter
10 changes: 9 additions & 1 deletion tests/out/rename-conflicting-binders.error
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
null
Error: Command failed: WARNING! hoisting var declaration over catch of same name: e
{ start: { line: 20, column: 8 },
end: { line: 20, column: 16 } }
WARNING! hoisting function declaration over catch of same name: f
{ start: { line: 28, column: 4 },
end: { line: 28, column: 24 } }
renamed binding for a would conflict
with existing binding for b in the same scope
{ line: 35, column: 40 } 'FunctionExpression Parameter'
9 changes: 8 additions & 1 deletion tests/out/rename-function-in-catch-1.error
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
null
Error: Command failed: WARNING! hoisting var declaration over catch of same name: e
{ start: { line: 20, column: 8 },
end: { line: 20, column: 16 } }
WARNING! hoisting function declaration over catch of same name: f
{ start: { line: 28, column: 4 },
end: { line: 28, column: 24 } }
cannot rename declaration hoisted over catch
f { line: 28, column: 13 }
9 changes: 8 additions & 1 deletion tests/out/rename-function-in-catch-2.error
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
null
Error: Command failed: WARNING! hoisting var declaration over catch of same name: e
{ start: { line: 20, column: 8 },
end: { line: 20, column: 16 } }
WARNING! hoisting function declaration over catch of same name: f
{ start: { line: 28, column: 4 },
end: { line: 28, column: 24 } }
cannot rename declaration hoisted over catch
f { line: 28, column: 13 }
9 changes: 8 additions & 1 deletion tests/out/rename-function-in-catch-3.error
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
null
Error: Command failed: WARNING! hoisting var declaration over catch of same name: e
{ start: { line: 20, column: 8 },
end: { line: 20, column: 16 } }
WARNING! hoisting function declaration over catch of same name: f
{ start: { line: 28, column: 4 },
end: { line: 28, column: 24 } }
cannot rename declaration hoisted over catch
f { line: 28, column: 13 }
8 changes: 7 additions & 1 deletion tests/out/rename-global-no-binder.error
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
null
Error: Command failed: WARNING! hoisting var declaration over catch of same name: e
{ start: { line: 20, column: 8 },
end: { line: 20, column: 16 } }
WARNING! hoisting function declaration over catch of same name: f
{ start: { line: 28, column: 4 },
end: { line: 28, column: 24 } }
no binding scope found
10 changes: 9 additions & 1 deletion tests/out/rename-introduce-catch-hoist-conflict.error
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
null
Error: Command failed: WARNING! hoisting var declaration over catch of same name: e
{ start: { line: 20, column: 8 },
end: { line: 20, column: 16 } }
WARNING! hoisting function declaration over catch of same name: f
{ start: { line: 28, column: 4 },
end: { line: 28, column: 24 } }
renamed occurrences of ff would be captured
by existing bindings for f
ff { line: 42, column: 6 } by f { line: 41, column: 9 } CatchClause Parameter
2 changes: 1 addition & 1 deletion tests/out/rename-invalid-newName.error
Original file line number Diff line number Diff line change
@@ -1 +1 @@
null
Error: Command failed: not a valid variable name >new-name<
2 changes: 1 addition & 1 deletion tests/out/rename-invalid-oldName.error
Original file line number Diff line number Diff line change
@@ -1 +1 @@
null
Error: Command failed: not a valid variable name >old-name<
9 changes: 8 additions & 1 deletion tests/out/rename-var-in-catch.error
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
null
Error: Command failed: WARNING! hoisting var declaration over catch of same name: e
{ start: { line: 20, column: 8 },
end: { line: 20, column: 16 } }
WARNING! hoisting function declaration over catch of same name: f
{ start: { line: 28, column: 4 },
end: { line: 28, column: 24 } }
cannot rename declaration hoisted over catch
e { line: 20, column: 8 }
8 changes: 7 additions & 1 deletion tests/out/rename-wrong-position.error
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
null
Error: Command failed: WARNING! hoisting var declaration over catch of same name: e
{ start: { line: 20, column: 8 },
end: { line: 20, column: 16 } }
WARNING! hoisting function declaration over catch of same name: f
{ start: { line: 28, column: 4 },
end: { line: 28, column: 24 } }
no binding scope found

0 comments on commit c883949

Please sign in to comment.