This repository was archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.js
More file actions
62 lines (47 loc) · 1.79 KB
/
Copy pathrun.js
File metadata and controls
62 lines (47 loc) · 1.79 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const childProcess = require('child_process');
const fs = require('fs-extra');
const path = require('path');
const dir = fs.readdirSync(__dirname);
let exit = 0;
const red = '\x1b[31m%s\x1b[0m';
const green = '\x1b[32m%s\x1b[0m';
function p(...args) {
return path.resolve(...args);
}
for (const dirPath of dir) {
console.log(`Testing ${dirPath}`);
const rootPath = p(__dirname, '..');
const srcFiles = ['package.json', 'index.js', 'src/get_typescript_compiler.js', 'src/tsc_preprocessor.js'];
const resolvedDirPath = p(__dirname, dirPath);
const dirPathStat = fs.statSync(resolvedDirPath);
const karmaCommand = 'node_modules/.bin/karma';
const tempDirs = [];
if (dirPathStat.isDirectory()) {
const commandPath = `tests/integration/${dirPath}`;
const subDir = p(resolvedDirPath, 'node_modules');
fs.removeSync(subDir);
fs.copySync(p(rootPath, 'node_modules'), subDir);
tempDirs.push(subDir);
if (dirPath === 'oldTsc') {
childProcess.spawnSync(`npm`, ['install', 'typescript@2.0.0'], { cwd: resolvedDirPath, stdio: 'inherit' });
}
// Make karma-tsc-preprocessor
const karmaTscPreprocessorPath = p(resolvedDirPath, 'node_modules', 'karma-tsc-preprocessor');
fs.removeSync(karmaTscPreprocessorPath);
for (const srcFile of srcFiles) {
fs.copySync(p(rootPath, srcFile), p(karmaTscPreprocessorPath, srcFile));
}
console.log(`${commandPath}$ ${karmaCommand} start`);
const result = childProcess.spawnSync(karmaCommand, ['start'], { cwd: resolvedDirPath, stdio: 'inherit' });
if (result.status !== 0) {
console.log(red, `${dirPath} - failed`);
exit = 1;
} else {
console.log(green, `${dirPath} - passed`);
}
for (const tempDir of tempDirs) {
fs.removeSync(tempDir);
}
}
}
process.exit(exit);