Skip to content

Commit 7801188

Browse files
committed
Bugfix: if a specific output filename was given and the file didn't exist already, the command wouldn't create it
1 parent 7cfb05e commit 7801188

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/CompileScssCommand.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
8080
$outputPath = rtrim($outputPath, '/');
8181

8282
if (!file_exists($outputPath)) {
83-
$this->writeNormal('The output path specified does not exist.', true);
84-
return 1;
83+
if (pathinfo($outputPath, PATHINFO_EXTENSION) != null) {
84+
// $outputPath has an extension, so assume it's a file path and check its parent is a directory
85+
$outputDir = pathinfo($outputPath, PATHINFO_DIRNAME);
86+
if (!file_exists($outputDir)) {
87+
$this->writeNormal("The output path $outputDir does not exist.", true);
88+
return 1;
89+
} else if(!is_dir($outputDir)) {
90+
$this->writeNormal("The output path $outputDir is not a directory.", true);
91+
return 1;
92+
}
93+
} else {
94+
$this->writeNormal("The output path $outputPath does not exist.", true);
95+
return 1;
96+
}
8597
}
8698

8799
if ($multiple && !is_dir($outputPath)) {

0 commit comments

Comments
 (0)