Skip to content

Commit 5082ca5

Browse files
committed
Sort config values
1 parent ed4589d commit 5082ca5

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 0.2.2 - 2021-08-04
4+
- Fixed: Triggers are now sorted to provide more stability across machines.
5+
36
## 0.2.1 - 2021-07-22
47
- Added `exclude_names` to both the FileTrigger and output config. This will let you ignore filenames, regardless of what folder they show up in. E.g. `.DS_Store`
58

src/HashGenerator.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,14 @@ public function asArray()
5050
foreach ($this->triggers as $class => $config) {
5151
$this->ensureContractImplemented($class);
5252

53-
$contents[$class] = app($class)->triggerBuildWhenChanged($config);
53+
$values = app($class)->triggerBuildWhenChanged($config);
54+
ksort($values);
55+
56+
$contents[$class] = $values;
5457
}
5558

59+
ksort($contents);
60+
5661
return $contents;
5762
}
5863

tests/HashCalculationTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Hammerstone\Airdrop\Tests;
77

88
use Hammerstone\Airdrop\HashGenerator;
9+
use Hammerstone\Airdrop\Triggers\ConfigTrigger;
910
use Hammerstone\Airdrop\Triggers\FileTrigger;
1011

1112
class HashCalculationTest extends BaseTest
@@ -33,4 +34,41 @@ public function it_tests_basic_file_hash()
3334

3435
$this->assertEquals('36eda7109ca99a5fb55cffefeca3c554', $hash);
3536
}
37+
38+
/** @test */
39+
public function it_gets_sorted()
40+
{
41+
config()->set('airdrop.triggers', [
42+
ConfigTrigger::class => [
43+
'a_key' => 'test',
44+
'b_key' => 'test'
45+
],
46+
FileTrigger::class => [
47+
'include' => [
48+
base_path('tests/Support/primary-webpack.mix.example'),
49+
base_path('tests/Support/secondary-webpack.mix.example'),
50+
]
51+
]
52+
]);
53+
54+
$hash1 = (new HashGenerator)->generate();
55+
56+
config()->set('airdrop.triggers', [
57+
FileTrigger::class => [
58+
'include' => [
59+
base_path('tests/Support/secondary-webpack.mix.example'),
60+
base_path('tests/Support/primary-webpack.mix.example'),
61+
]
62+
],
63+
ConfigTrigger::class => [
64+
'b_key' => 'test',
65+
'a_key' => 'test',
66+
],
67+
]);
68+
69+
$hash2 = (new HashGenerator)->generate();
70+
71+
$this->assertEquals($hash1, $hash2);
72+
73+
}
3674
}

0 commit comments

Comments
 (0)