Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(test): remove temp files after test run #960

Merged
merged 3 commits into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions @packages/test-environment/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@commitlint/test-environment",
"version": "8.3.5",
"description": "test environment for @commitlint",
"main": "lib/test-environment.js",
"types": "lib/test-environment.d.ts",
"files": [
"lib/"
],
"engines": {
"node": ">=8"
},
"repository": {
"type": "git",
"url": "https://github.com/conventional-changelog/commitlint.git"
},
"bugs": {
"url": "https://github.com/conventional-changelog/commitlint/issues"
},
"homepage": "https://github.com/conventional-changelog/commitlint#readme",
"keywords": [
"conventional-changelog",
"commitlint",
"test",
"cli"
],
"license": "MIT",
"dependencies": {
"@types/tmp": "^0.1.0",
"tmp": "0.1.0"
}
}
15 changes: 15 additions & 0 deletions @packages/test-environment/src/test-environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// https://github.com/raszi/node-tmp/issues/229
import NodeEnvironment from 'jest-environment-node';
import tmp from 'tmp';

class TestEnvironment extends NodeEnvironment {
async setup() {
await super.setup();

tmp.setGracefulCleanup();

this.global.tmp = tmp;
}
}

export default TestEnvironment;
15 changes: 15 additions & 0 deletions @packages/test-environment/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.shared.json",
"compilerOptions": {
"composite": true,
"rootDir": "./src",
"outDir": "./lib"
},
"include": [
"./src/**/*.ts"
],
"exclude": [
"./src/**/*.test.ts",
"./lib/**/*"
]
}
5 changes: 4 additions & 1 deletion @packages/test/src/fix.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import tmp from 'tmp';
import fs from 'fs-extra';
import path from 'path';
import pkgDir from 'pkg-dir';

declare global {
var tmp: typeof import('tmp');
}

export async function bootstrap(fixture?: string, directory?: string) {
const tmpDir = tmp.dirSync({
keep: false,
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
preset: 'ts-jest/presets/js-with-babel',
testEnvironment: 'node',
testEnvironment: '@commitlint/test-environment',
testRegex: undefined,
testMatch: [
'**/*.test.ts?(x)',
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"include": [],
"extends": "./tsconfig.shared.json",
"references": [
{ "path": "@packages/test-environment" },
{ "path": "@packages/test" },
{ "path": "@commitlint/ensure" },
{ "path": "@commitlint/execute-rule" },
Expand Down
12 changes: 1 addition & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2036,21 +2036,11 @@
resolved "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==

"@types/node@*":
version "12.0.2"
resolved "https://registry.npmjs.org/@types/node/-/node-12.0.2.tgz#3452a24edf9fea138b48fad4a0a028a683da1e40"
integrity sha512-5tabW/i+9mhrfEOUcLDu2xBPsHJ+X5Orqy9FKpale3SjDA17j5AEpYq5vfy3oAeAHGcvANRCO3NV3d2D6q3NiA==

"@types/[email protected]":
"@types/node@*", "@types/[email protected]", "@types/node@>= 8":
version "12.12.26"
resolved "https://registry.npmjs.org/@types/node/-/node-12.12.26.tgz#213e153babac0ed169d44a6d919501e68f59dea9"
integrity sha512-UmUm94/QZvU5xLcUlNR8hA7Ac+fGpO1EG/a8bcWVz0P0LqtxFmun9Y2bbtuckwGboWJIT70DoWq1r3hb56n3DA==

"@types/node@>= 8":
version "13.5.0"
resolved "https://registry.npmjs.org/@types/node/-/node-13.5.0.tgz#4e498dbf355795a611a87ae5ef811a8660d42662"
integrity sha512-Onhn+z72D2O2Pb2ql2xukJ55rglumsVo1H6Fmyi8mlU9SvKdBk/pUSUAiBY/d9bAOF7VVWajX3sths/+g6ZiAQ==

"@types/normalize-package-data@^2.4.0":
version "2.4.0"
resolved "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
Expand Down