Skip to content

Commit

Permalink
remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
thymikee committed Mar 26, 2019
1 parent 07104d9 commit a4001ad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
4 changes: 2 additions & 2 deletions e2e/__tests__/install.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import path from 'path';
import {runCli, getTempDirectory, cleanup, writeFiles} from '../helpers';
import {run, getTempDirectory, cleanup, writeFiles} from '../helpers';

const DIR = getTempDirectory('command-install-test');
const pkg = 'react-native-config';
Expand All @@ -18,7 +18,7 @@ test.each(['yarn', 'npm'])('install module with %s', pm => {
if (pm === 'yarn') {
writeFiles(DIR, {'yarn.lock': ''});
}
const {stdout, code} = runCli(DIR, ['install', pkg]);
const {stdout, code} = run(DIR, ['install', pkg]);

expect(stdout).toContain(`Installing "${pkg}"`);
expect(stdout).toContain(`Linking "${pkg}"`);
Expand Down
8 changes: 4 additions & 4 deletions e2e/__tests__/uninstall.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @flow
import {runCli, getTempDirectory, cleanup, writeFiles} from '../helpers';
import {run, getTempDirectory, cleanup, writeFiles} from '../helpers';

const DIR = getTempDirectory('command-uninstall-test');
const pkg = 'react-native-config';
Expand All @@ -24,7 +24,7 @@ test('uninstall fails when package is not defined', () => {
"dependencies": {}
}`,
});
const {stderr, code} = runCli(DIR, ['uninstall']);
const {stderr, code} = run(DIR, ['uninstall']);

expect(stderr).toContain('missing required argument');
expect(code).toBe(1);
Expand All @@ -36,7 +36,7 @@ test('uninstall fails when package is not installed', () => {
"dependencies": {}
}`,
});
const {stderr, code} = runCli(DIR, ['uninstall', pkg]);
const {stderr, code} = run(DIR, ['uninstall', pkg]);

expect(stderr).toContain(`Project "${pkg}" is not a react-native library`);
expect(code).toBe(1);
Expand All @@ -46,7 +46,7 @@ test.each(['yarn', 'npm'])('uninstall module with %s', pm => {
if (pm === 'yarn') {
writeFiles(DIR, {'yarn.lock': ''});
}
const {stdout, code} = runCli(DIR, ['uninstall', pkg]);
const {stdout, code} = run(DIR, ['uninstall', pkg]);

expect(stdout).toContain(`Unlinking "${pkg}"`);
expect(stdout).toContain(`Uninstalling "${pkg}"`);
Expand Down
22 changes: 8 additions & 14 deletions e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,31 @@ import os from 'os';
import path from 'path';
import {createDirectory} from 'jest-util';
import rimraf from 'rimraf';
import execa, {type SyncResult, type ThenableChildProcess} from 'execa';
import execa from 'execa';
import {Writable} from 'readable-stream';
import stripAnsi from 'strip-ansi';

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

type RunCliOptions = {
type RunOptions = {
nodeOptions?: string,
nodePath?: string,
stripAnsi?: boolean, // remove colors from stdout and stderr,
timeout?: number, // kill the process after X milliseconds
};

export function runCli(
export function run(
dir: string,
args?: Array<string>,
options: RunCliOptions = {},
options: RunOptions = {},
) {
return spawnCli(dir, args, options);
}

// Runs cli until a given output is achieved, then kills it with `SIGTERM`
export async function until(
export async function runUntil(
dir: string,
args: Array<string> | void,
text: string,
options: RunCliOptions = {},
options: RunOptions = {},
) {
const spawnPromise = spawnCliAsync(dir, args, {timeout: 30000, ...options});

Expand Down Expand Up @@ -108,11 +106,7 @@ export const copyDir = (src: string, dest: string) => {
export const getTempDirectory = (name: string) =>
path.resolve(os.tmpdir(), name);

function spawnCli(
dir: string,
args?: Array<string>,
options: RunCliOptions = {},
) {
function spawnCli(dir: string, args?: Array<string>, options: RunOptions = {}) {
const {spawnArgs, spawnOptions} = getCliArguments({dir, args, options});

return execa.sync(process.execPath, spawnArgs, spawnOptions);
Expand All @@ -121,7 +115,7 @@ function spawnCli(
function spawnCliAsync(
dir: string,
args?: Array<string>,
options: RunCliOptions = {},
options: RunOptions = {},
) {
const {spawnArgs, spawnOptions} = getCliArguments({dir, args, options});

Expand Down

0 comments on commit a4001ad

Please sign in to comment.