Skip to content

Commit

Permalink
Sort translation files by name to ensure same order on all systems
Browse files Browse the repository at this point in the history
Closes: #171.
  • Loading branch information
l3ku authored and Leo Toikka committed Jul 23, 2019
1 parent 2dee22e commit e2ded80
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/IterableCodeExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ function ( $file, $key, $iterator ) use ( $include, $exclude, $extensions ) {
$filtered_files[] = Utils\normalize_path( $file->getPathname() );
}

sort( $filtered_files, SORT_NATURAL | SORT_FLAG_CASE );

return $filtered_files;
}
}
13 changes: 13 additions & 0 deletions tests/IterableCodeExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,17 @@ public function test_can_override_exclude_by_include() {
$expected = static::$base . 'foo/bar/excluded/ignored.js';
$this->assertContains( $expected, $result );
}

public function test_can_return_all_directory_files_sorted() {
$result = IterableCodeExtractor::getFilesFromDirectory( self::$base, [ '*' ], [], [ 'php', 'js' ] );
$expected = array(
static::$base . 'baz/includes/should_be_included.js',
static::$base . 'foo-plugin/foo-plugin.php',
static::$base . 'foo/bar/excluded/ignored.js',
static::$base . 'foo/bar/foo/bar/foo/bar/deep_directory_also_included.php',
static::$base . 'foo/bar/foofoo/included.js',
static::$base . 'hoge/should_NOT_be_included.js',
);
$this->assertEquals( $expected, $result );
}
}

0 comments on commit e2ded80

Please sign in to comment.