Skip to content

Commit 3b61960

Browse files
authored
Merge pull request #358 from ADmad/skip-plugins
Allow skipping config files from plugins.
2 parents 324252e + 19b0cd6 commit 3b61960

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/Command/BuildCommand.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionPar
3838
'help' => 'The config file to use.',
3939
'short' => 'c',
4040
'default' => CONFIG . 'asset_compress.ini',
41+
])
42+
->addOption('skip-plugins', [
43+
'help' => 'Don\'t load config files from plugin\'s .',
44+
'boolean' => true,
4145
]);
4246

4347
return $parser;
@@ -53,7 +57,10 @@ public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionPar
5357
public function execute(Arguments $args, ConsoleIo $io)
5458
{
5559
$configFinder = new ConfigFinder();
56-
$config = $configFinder->loadAll($args->getOption('config'));
60+
$config = $configFinder->loadAll(
61+
$args->getOption('config'),
62+
(bool)$args->getOption('skip-plugins')
63+
);
5764
$factory = new Factory($config);
5865

5966
$themes = (array)$config->general('themes');

src/Config/ConfigFinder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ class ConfigFinder
2727
* will be loaded if it is present.
2828
*
2929
* @param string $path The configuration file path to start loading from.
30+
* @param bool $skipPlugins Whether to skip config files from plugins. Default `false`.
3031
* @return \MiniAsset\AssetConfig The completed configuration object.
3132
*/
32-
public function loadAll($path = null)
33+
public function loadAll($path = null, $skipPlugins = false)
3334
{
3435
if (!$path) {
3536
$path = CONFIG . 'asset_compress.ini';
@@ -39,6 +40,10 @@ public function loadAll($path = null)
3940
]);
4041
$this->_load($config, $path);
4142

43+
if ($skipPlugins) {
44+
return $config;
45+
}
46+
4247
$plugins = Plugin::loaded();
4348
foreach ($plugins as $plugin) {
4449
$pluginConfig = Plugin::path($plugin) . 'config' . DS . 'asset_compress.ini';

tests/TestCase/Config/ConfigFinderTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ public function testIniTargets()
7272
];
7373
$result = $config->targets();
7474
$this->assertEquals($expected, $result);
75+
76+
$config = $configFinder->loadAll($this->testConfig, true);
77+
78+
$expected = [
79+
'libs.js',
80+
'foo.bar.js',
81+
'new_file.js',
82+
'all.css',
83+
'pink.css',
84+
];
85+
$result = $config->targets();
86+
$this->assertEquals($expected, $result);
7587
}
7688

7789
public function testLocalPluginConfig()

0 commit comments

Comments
 (0)