|
1 | 1 | import { promises as fsP } from "fs"; |
2 | | -import * as fs from "fs" |
3 | | -import glob from "glob"; |
| 2 | +import * as fs from "fs"; |
| 3 | +import { glob } from "glob"; |
4 | 4 | import { js_beautify } from "js-beautify"; |
5 | 5 | import * as path from "path"; |
6 | 6 | import * as process from "process"; |
7 | | -import tempfile from "tempfile"; |
8 | | -import { toPromise } from "../src/util/util"; |
9 | 7 | import { programOutput } from "../src/api"; |
10 | | -import { compare } from "./util"; |
| 8 | +import { compare, tempfile } from "./util"; |
11 | 9 |
|
12 | 10 | const casesDir = path.normalize(__dirname + "/../../test/cases"); |
13 | 11 |
|
14 | 12 | main(); |
15 | 13 |
|
16 | 14 | function allCaseFilePaths(): Promise<string[]> { |
17 | | - return toPromise(cb => glob(`${casesDir}/*`, cb)); |
| 15 | + return glob(`${casesDir}/*`); |
18 | 16 | } |
19 | 17 |
|
20 | 18 | async function getExpectation(fileName: string): Promise<any> { |
21 | 19 | const tsIndex = fileName.lastIndexOf("."); |
22 | 20 | if (tsIndex !== -1) { |
23 | | - fileName = fileName.substr(0, tsIndex); |
| 21 | + fileName = fileName.substring(0, tsIndex); |
24 | 22 | } |
25 | 23 | const caseExpectationFile = fileName + ".expected.json"; |
26 | 24 | const expectedJsonFile = await fsP.readFile(caseExpectationFile); |
@@ -52,7 +50,7 @@ async function main() { |
52 | 50 |
|
53 | 51 | // run program on case |
54 | 52 | // convert output to json |
55 | | - const outputPath = tempfile(); |
| 53 | + const outputPath = await tempfile(); |
56 | 54 | try { |
57 | 55 | const resultObj = await runCase(caseFilePath, outputPath); |
58 | 56 | // read json expected for case |
|
0 commit comments