Skip to content
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
2 changes: 1 addition & 1 deletion src/Commands/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public function getDistfilesLines( string $source ): array {
*/
public function getDistincludeLines( string $source ): array {
$include = [];
$include_file = '.pup-include';
$include_file = '.pup-distinclude';

if ( ! file_exists( $source . $include_file ) ) {
return [];
Expand Down
30 changes: 20 additions & 10 deletions tests/cli/Commands/PackageCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,27 @@ public function it_should_package_the_zip_and_ignore_files_from_distignore_and_g
/**
* @test
*/
public function it_should_package_the_zip_and_include_files_in_distinclude( CliTester $I ) {
public function it_should_use_distinclude_as_a_filter_for_candidate_files( CliTester $I ) {
$this->reset_data_and_location();
$this->write_default_puprc();

chdir( $this->tests_root . '/_data/fake-project' );

file_put_contents( '.distinclude', ".puprc\n" );
// .distinclude with bootstrap.php means only bootstrap.php is a candidate.
file_put_contents( '.distinclude', "bootstrap.php\n" );

$I->runShellCommand( "php {$this->pup} package 1.0.0" );

system( 'unzip -d .pup-zip/ fake-project.1.0.0.zip' );

$I->runShellCommand( "ls -a .pup-zip" );

$I->runShellCommand( "find .pup-zip/fake-project -type f | sort" );
$output = $I->grabShellOutput();

// bootstrap.php passes the include filter
$I->assertStringContainsString( 'bootstrap.php', $output );
// other-file.php is excluded because it doesn't match .distinclude
$I->assertStringNotContainsString( 'other-file.php', $output );

$this->assertMatchesStringSnapshot( $output );

$I->runShellCommand( "php {$this->pup} clean" );
Expand All @@ -186,23 +192,27 @@ public function it_should_package_the_zip_and_include_files_in_distinclude( CliT
/**
* @test
*/
public function it_should_package_the_zip_and_include_files_in_distinclude_even_if_in_distignore_and_gitattributes( CliTester $I ) {
public function it_should_not_let_distinclude_override_distignore_and_gitattributes( CliTester $I ) {
$this->reset_data_and_location();
$this->write_default_puprc();

chdir( $this->tests_root . '/_data/fake-project' );

file_put_contents( '.distinclude', ".puprc\n" );
file_put_contents( '.distignore', ".puprc\n" );
file_put_contents( '.gitattributes', ".puprc export-ignore\n" );
// .distinclude allows bootstrap.php, but .distignore and .gitattributes exclude it.
file_put_contents( '.distinclude', "bootstrap.php\n" );
file_put_contents( '.distignore', "bootstrap.php\n" );
file_put_contents( '.gitattributes', "bootstrap.php export-ignore\n" );

$I->runShellCommand( "php {$this->pup} package 1.0.0" );

system( 'unzip -d .pup-zip/ fake-project.1.0.0.zip' );

$I->runShellCommand( "ls -a .pup-zip" );

$I->runShellCommand( "find .pup-zip/fake-project | sort" );
$output = $I->grabShellOutput();

// bootstrap.php should NOT be present — ignore rules still apply despite .distinclude
$I->assertStringNotContainsString( 'bootstrap.php', $output );

$this->assertMatchesStringSnapshot( $output );

$I->runShellCommand( "php {$this->pup} clean" );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.pup-zip/fake-project

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.pup-zip/fake-project/bootstrap.php