-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: UNIFINED <[email protected]>
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import fs from 'fs'; | ||
import path, {dirname} from 'path'; | ||
import assert from 'assert'; | ||
import {spawn} from 'child_process'; | ||
import syntaxError from 'syntax-error'; | ||
import {fileURLToPath} from 'url'; | ||
import {createRequire} from 'module'; | ||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
const require = createRequire(__dirname); | ||
const folders = ['.', ...Object.keys(require(path.join(__dirname, './package.json')).directories)]; | ||
const files = []; | ||
for (const folder of folders) { | ||
for (const file of fs.readdirSync(folder).filter((v) => v.endsWith('.js'))) { | ||
files.push(path.resolve(path.join(folder, file))); | ||
} | ||
} | ||
for (const file of files) { | ||
if (file == __filename) continue; | ||
console.error('Checking', file); | ||
const error = syntaxError(fs.readFileSync(file, 'utf8'), file, { | ||
sourceType: 'module', | ||
allowReturnOutsideFunction: true, | ||
allowAwaitOutsideFunction: true, | ||
}); | ||
if (error) assert.ok(error.length < 1, file + '\n\n' + error); | ||
assert.ok(file); | ||
console.log('Done', file); | ||
} |