forked from webtv-redialed/redialed-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
37 lines (35 loc) · 1.2 KB
/
test.js
File metadata and controls
37 lines (35 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const {promisify} = require("util");
const {resolve} = require("path");
const fs = require("fs");
const readdir = promisify(fs.readdir);
const stat = promisify(fs.stat);
const {exec} = require("child_process");
var path = require("path");
async function getFiles(dir) {
const subdirs = await readdir(dir);
const files = await Promise.all(
subdirs.map(async (subdir) => {
const res = resolve(dir, subdir);
return (await stat(res)).isDirectory() ? getFiles(res) : res;
})
);
return files.reduce((a, f) => a.concat(f), []);
}
getFiles(__dirname)
.then((files) => {
files.forEach(function (file) {
if (path.extname(file) == ".js" && file.indexOf("node_modules") == -1) {
console.log(
" * Checking syntax of",
file.replace(__dirname + path.sep, "." + path.sep)
);
exec('node --check "' + file + '"', (error, stdout, stderr) => {
if (stderr.length > 0) {
console.log(`${stderr}`);
return;
}
});
}
});
})
.catch((e) => console.error(e));