From b600845a1283f2b0a9d7e2cfc9d89bce262a95da Mon Sep 17 00:00:00 2001 From: Philipp Memmel Date: Thu, 7 Mar 2024 15:20:33 +0000 Subject: [PATCH] Limit stylelint tasks to plugin directory --- src/Command/GruntCommand.php | 9 +++++---- tests/Command/GruntCommandTest.php | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Command/GruntCommand.php b/src/Command/GruntCommand.php index f2415aef..8999389e 100644 --- a/src/Command/GruntCommand.php +++ b/src/Command/GruntCommand.php @@ -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': @@ -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; } diff --git a/tests/Command/GruntCommandTest.php b/tests/Command/GruntCommandTest.php index 669524ed..f7c3a592 100644 --- a/tests/Command/GruntCommandTest.php +++ b/tests/Command/GruntCommandTest.php @@ -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');