Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit stylelint tasks to plugin directory #278

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading