Skip to content

Commit 44e8267

Browse files
authored
Test
1 parent 1dcc473 commit 44e8267

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

test.js

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
1-
import fs from 'fs'
2-
import path, { dirname } from 'path'
3-
import assert from 'assert'
4-
import { spawn } from 'child_process'
5-
import syntaxError from 'syntax-error'
6-
import { fileURLToPath } from 'url'
7-
import { createRequire } from 'module'
1+
import fs from 'fs';
2+
import path, { dirname } from 'path';
3+
import assert from 'assert';
4+
import syntaxError from 'syntax-error';
5+
import { fileURLToPath } from 'url';
6+
import { createRequire } from 'module';
87

9-
const __filename = fileURLToPath(import.meta.url)
10-
const __dirname = dirname(__filename)
11-
const require = createRequire(__dirname)
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = dirname(__filename);
10+
const require = createRequire(__dirname);
11+
12+
let folders = ['.', ...Object.keys(require(path.join(__dirname, './package.json')).directories)];
13+
let files = [];
14+
15+
for (let folder of folders) {
16+
try {
17+
for (let file of fs.readdirSync(folder).filter(v => v.endsWith('.js'))) {
18+
files.push(path.resolve(path.join(folder, file)));
19+
}
20+
} catch (err) {
21+
console.error(`Error reading folder ${folder}:`, err);
22+
}
23+
}
1224

13-
let folders = ['.', ...Object.keys(require(path.join(__dirname, './package.json')).directories)]
14-
let files = []
15-
for (let folder of folders)
16-
for (let file of fs.readdirSync(folder).filter(v => v.endsWith('.js')))
17-
files.push(path.resolve(path.join(folder, file)))
1825
for (let file of files) {
19-
if (file == __filename) continue
20-
console.error('Checking', file)
26+
if (file == __filename) continue;
27+
console.error('Checking', file);
28+
2129
const error = syntaxError(fs.readFileSync(file, 'utf8'), file, {
2230
sourceType: 'module',
2331
allowReturnOutsideFunction: true,
2432
allowAwaitOutsideFunction: true
25-
})
26-
if (error) assert.ok(error.length < 1, file + '\n\n' + error)
27-
assert.ok(file)
28-
console.log('Done ☑️', file)
33+
});
34+
35+
assert.ifError(error);
36+
console.log('Done ☑️', file);
2937
}

0 commit comments

Comments
 (0)