Skip to content

Overwrite all files when not in non interactive mode #963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function shouldWriteFile(string $file, bool $overwrite): bool
exec('git status --short --ignored --untracked-files=all -- '.ProcessExecutor::escape($file).' 2>&1', $output, $status);

if (0 !== $status) {
return $this->io && $this->io->askConfirmation(\sprintf('Cannot determine the state of the "%s" file, overwrite anyway? [y/N] ', $file), false);
return $this->io && $this->io->askConfirmation(\sprintf('Cannot determine the state of the "%s" file, overwrite anyway? [Y/n] ', $file));
}

if (empty($output[0]) || preg_match('/^[ AMDRCU][ D][ \t]/', $output[0])) {
Expand All @@ -78,7 +78,7 @@ public function shouldWriteFile(string $file, bool $overwrite): bool
$name = basename($file);
$name = \strlen($output[0]) - \strlen($name) === strrpos($output[0], $name) ? substr($output[0], 3) : $name;

return $this->io && $this->io->askConfirmation(\sprintf('File "%s" has uncommitted changes, overwrite? [y/N] ', $name), false);
return $this->io && $this->io->askConfirmation(\sprintf('File "%s" has uncommitted changes, overwrite? [Y/n] ', $name));
}

public function toArray(): array
Expand Down
2 changes: 1 addition & 1 deletion tests/Configurator/CopyFromPackageConfiguratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testConfigureAndOverwriteFiles()

$this->io->expects($this->at(0))->method('writeError')->with([' Copying files from package']);
$this->io->expects($this->at(2))->method('writeError')->with([' Created <fg=green>"./public/file"</>']);
$this->io->method('askConfirmation')->with('File "build/public/file" has uncommitted changes, overwrite? [y/N] ')->willReturn(true);
$this->io->method('askConfirmation')->with('File "build/public/file" has uncommitted changes, overwrite? [Y/n] ')->willReturn(true);

$this->assertFileExists($this->targetFile);
$this->createConfigurator()->configure(
Expand Down
2 changes: 1 addition & 1 deletion tests/Configurator/CopyFromRecipeConfiguratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function testConfigureAndOverwriteFiles()

$this->io->expects($this->at(0))->method('writeError')->with([' Copying files from recipe']);
$this->io->expects($this->at(2))->method('writeError')->with([' Created <fg=green>"./config/file"</>']);
$this->io->method('askConfirmation')->with('File "build/config/file" has uncommitted changes, overwrite? [y/N] ')->willReturn(true);
$this->io->method('askConfirmation')->with('File "build/config/file" has uncommitted changes, overwrite? [Y/n] ')->willReturn(true);

$this->assertFileExists($this->targetFile);
$this->createConfigurator()->configure(
Expand Down
4 changes: 2 additions & 2 deletions tests/FlexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public function testInstallWithPackageJsonToSynchronizeSkipped()

$this->assertStringContainsString(
'Skip synchronizing package.json with PHP packages',
$io->getOutput(),
$io->getOutput()
);
}

Expand All @@ -339,7 +339,7 @@ public function testInstallWithoutPackageJsonToSynchronizeSkipped(array $extra)

$this->assertStringNotContainsString(
'Skip synchronizing package.json with PHP packages',
$io->getOutput(),
$io->getOutput()
);
}

Expand Down