Skip to content

Commit

Permalink
Merge pull request #278 from PhMemmel/Limit_stylelint_to_plugin_direc…
Browse files Browse the repository at this point in the history
…tory

Limit stylelint tasks to plugin directory
  • Loading branch information
stronk7 authored Jun 12, 2024
2 parents cdb52da + 6b5a114 commit 07d0f27
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
The format of this change log follows the advice given at [Keep a CHANGELOG](http://keepachangelog.com).

## [Unreleased]
### Fixed
- 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.

## [4.5.0] - 2024-06-03
### Changed
- 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.
Expand Down
9 changes: 5 additions & 4 deletions src/Command/GruntCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ public function toGruntTask(string $task): ?GruntTaskModel
if (is_file($this->plugin->directory . '/Gruntfile.js')) {
$workingDirectory = $this->plugin->directory;
}
$defaultTask = new GruntTaskModel($task, $workingDirectory);
$defaultTask = new GruntTaskModel($task, $workingDirectory);
$defaultTaskPluginDir = new GruntTaskModel($task, $this->plugin->directory);

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

return new GruntTaskModel($task, $this->moodle->directory);
case 'stylelint:css':
return $this->plugin->hasFilesWithName('*.css') ? $defaultTask : null;
return $this->plugin->hasFilesWithName('*.css') ? $defaultTaskPluginDir : null;
case 'stylelint:less':
return $this->plugin->hasFilesWithName('*.less') ? $defaultTask : null;
return $this->plugin->hasFilesWithName('*.less') ? $defaultTaskPluginDir : null;
case 'stylelint:scss':
return $this->plugin->hasFilesWithName('*.scss') ? $defaultTask : null;
return $this->plugin->hasFilesWithName('*.scss') ? $defaultTaskPluginDir : null;
default:
return $defaultTask;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/GruntCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function testToGruntTaskWithStyles()
$this->assertInstanceOf(GruntTaskModel::class, $task);
$this->assertSame('stylelint:css', $task->taskName);
$this->assertSame('', $task->buildDirectory);
$this->assertSame($this->moodleDir, $task->workingDirectory);
$this->assertSame($this->pluginDir, $task->workingDirectory);

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

Expand Down

0 comments on commit 07d0f27

Please sign in to comment.