Skip to content

Commit

Permalink
chore: fix code coverage, drop ncp
Browse files Browse the repository at this point in the history
  • Loading branch information
kjin committed May 2, 2019
1 parent 98f95e3 commit ff9a0e3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules/
!test/fixtures/loader/node_modules/
npm-debug.log
.coverage/
.DS_Store
.nyc_output/
.vscode/
Expand Down
22 changes: 0 additions & 22 deletions .nycrc

This file was deleted.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"@types/methods": "^1.1.0",
"@types/mocha": "^5.2.5",
"@types/mongoose": "^5.3.26",
"@types/ncp": "^2.0.1",
"@types/nock": "^10.0.0",
"@types/node": "~10.7.2",
"@types/once": "^1.4.0",
Expand All @@ -84,7 +83,6 @@
"jshint": "^2.9.1",
"linkinator": "^1.1.2",
"mocha": "^6.0.0",
"ncp": "^2.0.0",
"nock": "^10.0.0",
"nyc": "^14.0.0",
"once": "^1.4.0",
Expand Down
5 changes: 2 additions & 3 deletions scripts/report-coverage.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { BUILD_DIRECTORY, nodule, readFileP, forkP, spawnP } from './utils';
import { BUILD_DIRECTORY, nodule, forkP } from './utils';
import * as path from 'path';
import * as pify from 'pify';

export async function reportCoverage() {
await forkP(nodule('.bin/codecov'), [], {
await forkP(nodule('.bin/codecov'), [`--root=${path.resolve(BUILD_DIRECTORY, '..')}`], {
cwd: BUILD_DIRECTORY
});
}
10 changes: 6 additions & 4 deletions scripts/run-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ export async function runTests(options: Options) {
let testNum = 0;
const excludedFiles = ([] as string[])
.concat(...await Promise.all((excludeGlobs || []).map(glob => globP(glob))));
const includedFiles = ([] as string[])
.concat(...await Promise.all(includeGlobs.map(glob => globP(glob))));
// const includedFiles = ([] as string[])
// .concat(...await Promise.all(includeGlobs.map(glob => globP(glob))));
const includedFiles = ['build/test/plugins/test-trace-mongoose-async-await.js'];
// Take the difference
const files = includedFiles.filter(i => excludedFiles.indexOf(i) < 0);
for (const file of files) {
Expand All @@ -28,9 +29,10 @@ export async function runTests(options: Options) {
'--reporter',
'lcov',
'--report-dir',
`./coverage/${testNum++}`,
`./.coverage/${testNum++}`,
'--exclude',
'build/test/**'
'build/test/**',
"--all"
] : [],
nodule('mocha/bin/_mocha'),
'--require',
Expand Down
6 changes: 4 additions & 2 deletions scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { mkdir, Stats, stat, readFile, writeFile } from 'fs';
import * as glob from 'glob';
import { ncp } from 'ncp';
import * as path from 'path';
import * as pify from 'pify';
import { ChildProcess, ForkOptions, fork, SpawnOptions, spawn } from 'child_process';
Expand All @@ -11,12 +10,15 @@ export const BUILD_DIRECTORY = 'build';

export const globP: (pattern: string) => Promise<string[]> = pify(glob);
export const mkdirP: (dir: string) => Promise<void> = pify(mkdir);
export const ncpP: (src: string, dest: string) => Promise<void> = pify(ncp);
export const readFileP: (path: string, encoding?: string) => Promise<Buffer|string> = pify(readFile);
export const writeFileP: (path: string, data: Buffer|string, encoding?: string) => Promise<void> = pify(writeFile);
export const statP: (path: string) => Promise<Stats> = pify(stat);
export const tmpDirP: () => Promise<string> = pify(tmp.dir);

export async function ncpP(src: string, dest: string): Promise<void> {
await spawnP("cp", ["-r", src, dest]);
};

export function nodule(nodule: string) {
return path.relative(BUILD_DIRECTORY, `node_modules/${nodule}`);
}
Expand Down

0 comments on commit ff9a0e3

Please sign in to comment.