all-in-one: format source code
This commit is contained in:
parent
6e1e6fc83e
commit
0534ee9077
@ -7,7 +7,7 @@ function load(filename) {
|
|||||||
if (/[\/\\]/.test(filename))
|
if (/[\/\\]/.test(filename))
|
||||||
return fs.readFileSync(filename, 'utf8');
|
return fs.readFileSync(filename, 'utf8');
|
||||||
|
|
||||||
var PATH = [ '.', 'include', 'src' ];
|
var PATH = ['.', 'include', 'src'];
|
||||||
for (;;) {
|
for (;;) {
|
||||||
var dir = PATH.shift();
|
var dir = PATH.shift();
|
||||||
try {
|
try {
|
||||||
@ -57,7 +57,7 @@ function include(line, filename) {
|
|||||||
var key = path.basename(filename).toLowerCase();
|
var key = path.basename(filename).toLowerCase();
|
||||||
if (included[key])
|
if (included[key])
|
||||||
return comment(line);
|
return comment(line);
|
||||||
console.error("Including: " + key);
|
console.error('Including: ' + key);
|
||||||
included[key] = true;
|
included[key] = true;
|
||||||
return lines(filename);
|
return lines(filename);
|
||||||
}
|
}
|
||||||
@ -78,8 +78,8 @@ for (var i = 2; i < process.argv.length; i++) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var patterns = [
|
var patterns = [
|
||||||
{re : /^\s*#include\s*"([^"]*)".*$/, fn : include},
|
{re: /^\s*#include\s*"([^"]*)".*$/, fn: include},
|
||||||
{re : /^\s*#include\s*<([^"]*)>.*$/, fn : include_sys}
|
{re: /^\s*#include\s*<([^"]*)>.*$/, fn: include_sys}
|
||||||
]
|
]
|
||||||
|
|
||||||
restart: for (var lno = 0; lno < source.length;) {
|
restart: for (var lno = 0; lno < source.length;) {
|
||||||
@ -90,7 +90,7 @@ restart: for (var lno = 0; lno < source.length;) {
|
|||||||
if (match) {
|
if (match) {
|
||||||
var repl = pattern.fn.apply(null, match);
|
var repl = pattern.fn.apply(null, match);
|
||||||
if (repl != null && repl !== line) {
|
if (repl != null && repl !== line) {
|
||||||
source.splice.apply(source, [ lno, 1 ].concat(repl));
|
source.splice.apply(source, [lno, 1].concat(repl));
|
||||||
continue restart;
|
continue restart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user