Skip to content

Commit 07d0f27

Browse files
authored
Merge pull request #278 from PhMemmel/Limit_stylelint_to_plugin_directory
Limit stylelint tasks to plugin directory
2 parents cdb52da + 6b5a114 commit 07d0f27

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

docs/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
99
The format of this change log follows the advice given at [Keep a CHANGELOG](http://keepachangelog.com).
1010

1111
## [Unreleased]
12+
### Fixed
13+
- Fixed a problem with the `grunt` command running the `stylelint` tasks against the whole Moodle directory (including both core and other optional plugins installed). Now only the plugin being checked is effectively analysed.
14+
1215
## [4.5.0] - 2024-06-03
1316
### Changed
1417
- Updated project dependencies to current [moodle-cs v3.4.7](https://github.com/moodlehq/moodle-cs) and [moodle-local_ci v1.0.30](https://github.com/moodlehq/moodle-local_ci) releases.

src/Command/GruntCommand.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ public function toGruntTask(string $task): ?GruntTaskModel
169169
if (is_file($this->plugin->directory . '/Gruntfile.js')) {
170170
$workingDirectory = $this->plugin->directory;
171171
}
172-
$defaultTask = new GruntTaskModel($task, $workingDirectory);
172+
$defaultTask = new GruntTaskModel($task, $workingDirectory);
173+
$defaultTaskPluginDir = new GruntTaskModel($task, $this->plugin->directory);
173174

174175
switch ($task) {
175176
case 'amd':
@@ -194,11 +195,11 @@ public function toGruntTask(string $task): ?GruntTaskModel
194195

195196
return new GruntTaskModel($task, $this->moodle->directory);
196197
case 'stylelint:css':
197-
return $this->plugin->hasFilesWithName('*.css') ? $defaultTask : null;
198+
return $this->plugin->hasFilesWithName('*.css') ? $defaultTaskPluginDir : null;
198199
case 'stylelint:less':
199-
return $this->plugin->hasFilesWithName('*.less') ? $defaultTask : null;
200+
return $this->plugin->hasFilesWithName('*.less') ? $defaultTaskPluginDir : null;
200201
case 'stylelint:scss':
201-
return $this->plugin->hasFilesWithName('*.scss') ? $defaultTask : null;
202+
return $this->plugin->hasFilesWithName('*.scss') ? $defaultTaskPluginDir : null;
202203
default:
203204
return $defaultTask;
204205
}

tests/Command/GruntCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function testToGruntTaskWithStyles()
140140
$this->assertInstanceOf(GruntTaskModel::class, $task);
141141
$this->assertSame('stylelint:css', $task->taskName);
142142
$this->assertSame('', $task->buildDirectory);
143-
$this->assertSame($this->moodleDir, $task->workingDirectory);
143+
$this->assertSame($this->pluginDir, $task->workingDirectory);
144144

145145
$this->fs->remove($this->pluginDir . '/styles.css');
146146

0 commit comments

Comments
 (0)