Skip to content

Commit df491ec

Browse files
author
Fake Fake
committed
finally resolve snapshot issues
1 parent afb54ae commit df491ec

6 files changed

+30
-15
lines changed

src/Filesystem/SyncFiles/AbstractFile.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
use Symfony\Component\Finder\Glob;
66

77
class AbstractFile {
8+
/**
9+
* An array of our default files.
10+
*
11+
* @var array<int, string>
12+
*/
13+
protected const DEFAULTS = [
14+
'.distignore-defaults',
15+
'.puprc-defaults'
16+
];
17+
818
/**
919
* @var string
1020
*/
@@ -94,12 +104,15 @@ public function writeContents( string $target_file ): string {
94104

95105
foreach ( $this->getPaths() as $file ) {
96106
if ( ! file_exists( $this->getRoot() . $file ) ) {
97-
if ( ! file_exists( $file ) || false !== strpos( $file, __PUP_DIR__ ) === false ) {
98-
$is_default = true;
107+
if ( ! file_exists( $file ) ) {
99108
continue;
100-
} else {
101-
$path = $file;
102109
}
110+
111+
if ( $this->is_default( $file ) ) {
112+
$is_default = true;
113+
}
114+
115+
$path = $file;
103116
} else {
104117
$path = $this->getRoot() . $file;
105118
}
@@ -146,6 +159,10 @@ public function writeContents( string $target_file ): string {
146159
return (string) file_get_contents( $this->getRoot() . $target_file );
147160
}
148161

162+
public function is_default( string $file ): bool {
163+
return in_array( $file, array_map( fn( $default_file ) => __PUP_DIR__ . '/' . $default_file, static::DEFAULTS ), true );
164+
}
165+
149166
/**
150167
* Writes the file.
151168
*

tests/cli/Commands/PackageCest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,6 @@ public function it_should_package_the_zip_and_use_default_distignore_when_no_saf
223223

224224
$output .= $I->grabShellOutput();
225225

226-
$I->runShellCommand( "ls -a node_modules" );
227-
228-
$output .= $I->grabShellOutput();
229-
230226
$this->assertMatchesStringSnapshot( $output );
231227
}
232228

tests/cli/Commands/__snapshots__/BuildCest__it_should_run_build__0.snapshot.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Running build steps...
55

66
.
77
..
8+
.pup-zip
89
.puprc
910
bootstrap.php
1011
node_modules
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
.
22
..
3-
.distignore
43
fake-project
5-
node_modules
64
other-file.php
7-
package.json
85
src
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
.
22
..
3-
.distignore
4-
.gitattributes
53
fake-project
6-
node_modules
7-
package.json
84
src
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.
2+
..
3+
bootstrap.php
4+
fake-project
5+
src.
6+
..
7+
OtherFileWithBadVersion.php
8+
Plugin.php

0 commit comments

Comments
 (0)