Skip to content

Commit

Permalink
fix: delete unused utils
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonrybczak committed Nov 2, 2023
1 parent 6f2908b commit 6433b2a
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 56 deletions.
48 changes: 1 addition & 47 deletions jest/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {createDirectory} from 'jest-util';
import execa from 'execa';
import chalk from 'chalk';
import slash from 'slash';
import {Writable} from 'readable-stream';

const CLI_PATH = path.resolve(__dirname, '../packages/cli/build/bin.js');

Expand All @@ -32,38 +31,6 @@ export function runCLI(
});
}

// Runs cli until a given output is achieved, then kills it with `SIGTERM`
export async function runUntil(
dir: string,
args: string[] | undefined,
text: string,
options: RunOptions = {
expectedFailure: false,
},
) {
const spawnPromise = spawnScriptAsync(dir, args || [], {
timeout: 30000,
cwd: dir,
...options,
});

spawnPromise.stderr?.pipe(
new Writable({
write(chunk: any, _encoding: string, callback: () => void) {
const output = chunk.toString('utf8');

if (output.includes(text)) {
spawnPromise.kill();
}

callback();
},
}),
);

return spawnPromise;
}

export const makeTemplate =
(str: string): ((values?: Array<any>) => string) =>
(values?: Array<any>) =>
Expand Down Expand Up @@ -133,7 +100,7 @@ type SpawnFunction<T> = (
options: SpawnOptions,
) => T;

export const spawnScript: SpawnFunction<execa.ExecaReturns> = (
export const spawnScript: SpawnFunction<execa.ExecaReturnBase<string>> = (
execPath,
args,
options,
Expand All @@ -145,19 +112,6 @@ export const spawnScript: SpawnFunction<execa.ExecaReturns> = (
return result;
};

const spawnScriptAsync: SpawnFunction<execa.ExecaChildProcess> = (
execPath,
args,
options,
) => {
try {
return execa(execPath, args, getExecaOptions(options));
} catch (result) {
handleTestFailure(execPath, options, result, args);
return result;
}
};

function getExecaOptions(options: SpawnOptions) {
const isRelative = !path.isAbsolute(options.cwd);

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"@types/jest": "^26.0.15",
"@types/node": "^18.0.0",
"@types/node-fetch": "^2.3.7",
"@types/readable-stream": "^2.3.0",
"babel-jest": "^26.6.2",
"babel-plugin-module-resolver": "^3.2.0",
"chalk": "^4.1.2",
Expand Down
8 changes: 0 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2392,14 +2392,6 @@
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.3.tgz#7ee330ba7caafb98090bece86a5ee44115904c2c"
integrity sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==

"@types/readable-stream@^2.3.0":
version "2.3.15"
resolved "https://registry.yarnpkg.com/@types/readable-stream/-/readable-stream-2.3.15.tgz#3d79c9ceb1b6a57d5f6e6976f489b9b5384321ae"
integrity sha512-oM5JSKQCcICF1wvGgmecmHldZ48OZamtMxcGGVICOJA8o8cahXC1zEVAif8iwoc5j8etxFaRFnf095+CDsuoFQ==
dependencies:
"@types/node" "*"
safe-buffer "~5.1.1"

"@types/semver@^6.0.2":
version "6.2.1"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-6.2.1.tgz#a236185670a7860f1597cf73bea2e16d001461ba"
Expand Down

0 comments on commit 6433b2a

Please sign in to comment.