Skip to content

Commit

Permalink
Remove superfluous dependencies
Browse files Browse the repository at this point in the history
* Remove get-stream dependency
* Remove delay dependency
* Remove fs-extra
* Remove temp-write
  • Loading branch information
novemberborn committed Jun 25, 2023
1 parent fae3f87 commit 6f62c2d
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 146 deletions.
90 changes: 0 additions & 90 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,10 @@
"@sindresorhus/tsconfig": "^3.0.1",
"ansi-escapes": "^6.2.0",
"c8": "^7.13.0",
"delay": "^5.0.0",
"execa": "^7.1.1",
"expect": "^29.5.0",
"fs-extra": "^11.1.1",
"get-stream": "^6.0.1",
"sinon": "^15.1.0",
"tap": "^16.3.4",
"temp-write": "^5.0.0",
"tempy": "^3.0.0",
"touch": "^3.1.0",
"tsd": "^0.28.1",
Expand Down
47 changes: 19 additions & 28 deletions test-tap/code-excerpt.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import fs from 'node:fs';
import {pathToFileURL} from 'node:url';

import {Chalk} from 'chalk'; // eslint-disable-line unicorn/import-style
import {test} from 'tap';
import tempWrite from 'temp-write';
import {temporaryFile, temporaryWriteSync} from 'tempy';

import {set as setChalk} from '../lib/chalk.js';
import codeExcerpt from '../lib/code-excerpt.js';
Expand All @@ -13,11 +12,9 @@ setChalk({level: 1});
const chalk = new Chalk({level: 1});

test('read code excerpt', t => {
const file = pathToFileURL(tempWrite.sync([
'function a() {',
'\talert();',
'}',
].join('\n')));
const file = pathToFileURL(temporaryWriteSync(`function a() {
alert();
}`));

const excerpt = codeExcerpt({file, line: 2, isWithinProject: true, isDependency: false});
const expected = [
Expand All @@ -31,11 +28,9 @@ test('read code excerpt', t => {
});

test('truncate lines', t => {
const file = pathToFileURL(tempWrite.sync([
'function a() {',
'\talert();',
'}',
].join('\n')));
const file = pathToFileURL(temporaryWriteSync(`function a() {
alert();
}`));

const excerpt = codeExcerpt({file, line: 2, isWithinProject: true, isDependency: false}, {maxWidth: 14});
const expected = [
Expand All @@ -49,19 +44,17 @@ test('truncate lines', t => {
});

test('format line numbers', t => {
const file = pathToFileURL(tempWrite.sync([
'',
'',
'',
'',
'',
'',
'',
'',
'function a() {',
'\talert();',
'}',
].join('\n')));
const file = pathToFileURL(temporaryWriteSync(`
function a() {
alert();
}`));

const excerpt = codeExcerpt({file, line: 10, isWithinProject: true, isDependency: false});
const expected = [
Expand All @@ -75,9 +68,7 @@ test('format line numbers', t => {
});

test('noop if file cannot be read', t => {
const file = pathToFileURL(tempWrite.sync(''));
fs.unlinkSync(file);

const file = pathToFileURL(temporaryFile());
const excerpt = codeExcerpt({file, line: 10, isWithinProject: true, isDependency: false});
t.equal(excerpt, null);
t.end();
Expand Down
2 changes: 1 addition & 1 deletion test-tap/fixture/fail-fast/timeout/fails.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const delay = require('delay');
const {setTimeout: delay} = require('node:timers/promises');

const test = require('../../../../entrypoints/main.cjs');

Expand Down
2 changes: 1 addition & 1 deletion test-tap/fixture/fail-fast/timeout/passes-slow.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const delay = require('delay');
const {setTimeout: delay} = require('node:timers/promises');

const test = require('../../../../entrypoints/main.cjs');

Expand Down
2 changes: 1 addition & 1 deletion test-tap/fixture/long-running.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const delay = require('delay');
const {setTimeout: delay} = require('node:timers/promises');

const test = require('../../entrypoints/main.cjs');

Expand Down
2 changes: 1 addition & 1 deletion test-tap/fixture/report/timeoutcontextlogs/a.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const delay = require('delay');
const {setTimeout: delay} = require('node:timers/promises');

const test = require('../../../../entrypoints/main.cjs');

Expand Down
2 changes: 1 addition & 1 deletion test-tap/fixture/report/timeoutcontextlogs/b.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const delay = require('delay');
const {setTimeout: delay} = require('node:timers/promises');

const test = require('../../../../entrypoints/main.cjs');

Expand Down
2 changes: 1 addition & 1 deletion test-tap/fixture/report/timeoutinmultiplefiles/a.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const delay = require('delay');
const {setTimeout: delay} = require('node:timers/promises');

const test = require('../../../../entrypoints/main.cjs');

Expand Down
2 changes: 1 addition & 1 deletion test-tap/fixture/report/timeoutinmultiplefiles/b.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const delay = require('delay');
const {setTimeout: delay} = require('node:timers/promises');

const test = require('../../../../entrypoints/main.cjs');

Expand Down
2 changes: 1 addition & 1 deletion test-tap/fixture/report/timeoutinsinglefile/a.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const delay = require('delay');
const {setTimeout: delay} = require('node:timers/promises');

const test = require('../../../../entrypoints/main.cjs');

Expand Down
2 changes: 1 addition & 1 deletion test-tap/fixture/report/timeoutwithmatch/a.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const delay = require('delay');
const {setTimeout: delay} = require('node:timers/promises');

const test = require('../../../../entrypoints/main.cjs');

Expand Down
2 changes: 1 addition & 1 deletion test-tap/fixture/serial.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const delay = require('delay');
const {setTimeout: delay} = require('node:timers/promises');

const test = require('../../entrypoints/main.cjs');

Expand Down
6 changes: 2 additions & 4 deletions test-tap/helper/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import childProcess from 'node:child_process';
import path from 'node:path';
import {fileURLToPath} from 'node:url';

import getStream from 'get-stream';

const __dirname = fileURLToPath(new URL('.', import.meta.url));
const cliPath = fileURLToPath(new URL('../../entrypoints/cli.mjs', import.meta.url));

Expand Down Expand Up @@ -48,8 +46,8 @@ export function execCli(args, options, cb) {
resolve(code);
});

stdout = getStream(child.stdout);
stderr = getStream(child.stderr);
stdout = child.stdout.toArray().then(chunks => chunks.join(''));
stderr = child.stderr.toArray().then(chunks => chunks.join(''));
});

Promise.all([processPromise, stdout, stderr]).then(args => {
Expand Down
3 changes: 1 addition & 2 deletions test-tap/helper/replay-report.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import fs from 'node:fs';

import delay from 'delay';
import {setTimeout as delay} from 'node:timers/promises';

import TTYStream from './tty-stream.js';

Expand Down
3 changes: 2 additions & 1 deletion test-tap/runner.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import delay from 'delay';
import {setTimeout as delay} from 'node:timers/promises';

import {test} from 'tap';

import Runner from '../lib/runner.js';
Expand Down
3 changes: 2 additions & 1 deletion test-tap/test-try-commit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import delay from 'delay';
import {setTimeout as delay} from 'node:timers/promises';

import {test} from 'tap';

import ContextRef from '../lib/context-ref.js';
Expand Down
10 changes: 7 additions & 3 deletions test-tap/test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'node:path';
import {setTimeout as delay} from 'node:timers/promises';
import {fileURLToPath} from 'node:url';

import ciInfo from 'ci-info';
import delay from 'delay';
import sinon from 'sinon';
import {test} from 'tap';

Expand Down Expand Up @@ -312,7 +312,9 @@ test('throws and notThrows work with promises', t => {
const instance = ava(a => {
a.plan(2);
return Promise.all([
a.throwsAsync(delay.reject(10, {value: new Error('foo')}), {message: 'foo'}),
a.throwsAsync(delay(10).then(() => {
throw new Error('foo');
}), {message: 'foo'}),
a.notThrowsAsync(delay(20).then(() => {
asyncCalled = true;
})),
Expand All @@ -332,7 +334,9 @@ test('multiple resolving and rejecting promises passed to t.throws/t.notThrows',
const promises = [];
for (let i = 0; i < 3; i++) {
promises.push(
a.throwsAsync(delay.reject(10, {value: new Error('foo')}), {message: 'foo'}),
a.throwsAsync(delay(10).then(() => {
throw new Error('foo');
}), {message: 'foo'}),
a.notThrowsAsync(delay(10)),
);
}
Expand Down
5 changes: 3 additions & 2 deletions test/helpers/with-temporary-fixture.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import fse from 'fs-extra';
import fs from 'node:fs/promises';

import {temporaryDirectoryTask} from 'tempy';

export async function withTemporaryFixture(cwd, task) {
let result;
await temporaryDirectoryTask(async temporary => {
await fse.copy(cwd, temporary);
await fs.cp(cwd, temporary, {recursive: true});
result = await task(temporary);
});

Expand Down
3 changes: 2 additions & 1 deletion test/shared-workers/timeout/fixtures/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {setTimeout as delay} from 'node:timers/promises';

import test from 'ava';
import {registerSharedWorker} from 'ava/plugin';
import delay from 'delay';

registerSharedWorker({
filename: new URL('worker.mjs', import.meta.url),
Expand Down

0 comments on commit 6f62c2d

Please sign in to comment.