Skip to content

Commit

Permalink
Limit stylelint tasks to plugin directory
Browse files Browse the repository at this point in the history
  • Loading branch information
PhMemmel authored and stronk7 committed Jun 12, 2024
1 parent cdb52da commit b600845
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
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 b600845

Please sign in to comment.