Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

[expo-cli] fix init visual regression #3173

Merged
merged 1 commit into from
Feb 2, 2021
Merged
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
17 changes: 8 additions & 9 deletions packages/expo-cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import { UserManager, Versions } from '@expo/xdl';
import chalk from 'chalk';
import program, { Command } from 'commander';
import fs from 'fs-extra';
import padEnd from 'lodash/padEnd';
import trimStart from 'lodash/trimStart';
import npmPackageArg from 'npm-package-arg';
import pacote from 'pacote';
import path from 'path';
import stripAnsi from 'strip-ansi';
import terminalLink from 'terminal-link';
import wrapAnsi from 'wrap-ansi';

import CommandError, { SilentError } from '../CommandError';
import log from '../log';
Expand Down Expand Up @@ -155,6 +153,12 @@ async function resolveProjectRootAsync(input?: string): Promise<string> {
return projectRoot;
}

function padEnd(str: string, width: number): string {
// Pulled from commander for overriding
const len = Math.max(0, width - stripAnsi(str).length);
return str + Array(len + 1).join(' ');
}

async function action(projectDir: string, command: Command) {
const options = parseOptions(command);

Expand Down Expand Up @@ -232,12 +236,7 @@ async function action(projectDir: string, command: Command) {
value: template.name,
title:
chalk.bold(padEnd(template.shortName, descriptionColumn)) +
trimStart(
wrapAnsi(
template.description,
Math.min(descriptionColumn + 2, process.stdout.columns || 80)
)
),
template.description.trim(),
short: template.name,
};
}
Expand Down