Skip to content

Commit 9a50cb6

Browse files
Alex Eaglealexeagle
Alex Eagle
authored andcommitted
chore(karma): remove dependency on tmp
1 parent 0c3bce6 commit 9a50cb6

File tree

5 files changed

+9
-16
lines changed

5 files changed

+9
-16
lines changed

packages/karma/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ ts_library(
3030
tsconfig = ":tsconfig.json",
3131
deps = [
3232
"@npm//@types/node",
33-
"@npm//tmp",
3433
],
3534
)
3635

@@ -46,7 +45,6 @@ nodejs_binary(
4645
"@npm//karma-requirejs",
4746
"@npm//karma-sourcemap-loader",
4847
"@npm//requirejs",
49-
"@npm//tmp",
5048
],
5149
entry_point = "@npm//:node_modules/karma/bin/karma",
5250
)

packages/karma/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import * as fs from 'fs';
66
import * as path from 'path';
77
import * as process from 'process';
88
import {createInterface} from 'readline';
9-
import * as tmp from 'tmp';
109
///<reference types="lib.dom"/>
1110

1211
/**
@@ -24,14 +23,14 @@ function sha1(data) {
2423
function initConcatJs(logger, emitter, basePath, hostname, port) {
2524
const log = logger.create('framework.concat_js');
2625

27-
// Create a tmp file for the concat bundle that is automatically cleaned up on
28-
// exit.
29-
const tmpFile = tmp.fileSync({keep: false, dir: process.env['TEST_TMPDIR']});
26+
// Create a tmp file for the concat bundle, rely on Bazel to clean the TMPDIR
27+
const tmpFile =
28+
path.join(process.env['TEST_TMPDIR'], crypto.randomBytes(6).readUIntLE(0, 6).toString(36));
3029

3130
emitter.on('file_list_modified', files => {
3231
const bundleFile = {
3332
path: '/concatjs_bundle.js',
34-
contentPath: tmpFile.name,
33+
contentPath: tmpFile,
3534
isUrl: false,
3635
content: '',
3736
encodings: {},

packages/karma/karma.conf.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Karma configuration
22
// GENERATED BY Bazel
33
try {
4+
const crypto = require('crypto');
45
const fs = require('fs');
56
const path = require('path');
6-
const tmp = require('tmp');
77
const child_process = require('child_process');
88
const runfiles = require(process.env['BAZEL_NODE_RUNFILES_HELPER']);
99

@@ -272,10 +272,10 @@ try {
272272
})();
273273
`;
274274

275-
const requireConfigFile =
276-
tmp.fileSync({keep: false, postfix: '.js', dir: process.env['TEST_TMPDIR']});
277-
fs.writeFileSync(requireConfigFile.name, requireConfigContent);
278-
conf.files.push(requireConfigFile.name);
275+
const requireConfigFile = path.join(
276+
process.env['TEST_TMPDIR'], crypto.randomBytes(6).readUIntLE(0, 6).toString(36) + '.js');
277+
fs.writeFileSync(requireConfigFile, requireConfigContent);
278+
conf.files.push(requireConfigFile);
279279
}
280280

281281
/**

packages/karma/karma_web_test.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ KARMA_PEER_DEPS = [
2929
"@npm//karma-requirejs",
3030
"@npm//karma-sourcemap-loader",
3131
"@npm//requirejs",
32-
"@npm//tmp",
3332
]
3433

3534
KARMA_WEB_TEST_ATTRS = {

packages/karma/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
],
1818
"main": "./index.js",
1919
"typings": "./index.d.ts",
20-
"dependencies": {
21-
"tmp": "0.1.0"
22-
},
2320
"peerDependencies": {
2421
"jasmine-core": ">=2.0.0",
2522
"karma": ">=4.0.0",

0 commit comments

Comments
 (0)