Skip to content

Commit

Permalink
Combine imports/import files earlier
Browse files Browse the repository at this point in the history
If we wait until after adjusting the paths relative to the new
target, we may fail to import them because the path they'll be
relative to may not yet exist.

If we do it after moving path
  • Loading branch information
matthiasmullie committed Jan 7, 2016
1 parent 3da112a commit bf87a5c
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 15 deletions.
10 changes: 4 additions & 6 deletions src/CSS.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,22 +314,20 @@ public function execute($path = null)
// restore the string we've extracted earlier
$css = $this->restoreExtractedData($css);

$source = $source ?: '';
$css = $this->combineImports($source, $css);
$css = $this->importFiles($source, $css);

/*
* If we'll save to a new path, we'll have to fix the relative paths
* to be relative no longer to the source file, but to the new path.
* If we don't write to a file, fall back to same path so no
* conversion happens (because we still want it to go through most
* of the move code...)
*/
$source = $source ?: '';
$converter = new Converter($source, $path ?: $source);
$css = $this->move($converter, $css);

// if no target path is given, relative paths were not converted, so
// they'll still be relative to the source file then
$css = $this->importFiles($path ?: $source, $css);
$css = $this->combineImports($path ?: $source, $css);

// combine css
$content .= $css;
}
Expand Down
4 changes: 0 additions & 4 deletions tests/css/sample/convert_relative_path/target/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion tests/css/sample/convert_relative_path/target/relative.css

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions tests/css/sample/symlink/target/.gitignore

This file was deleted.

0 comments on commit bf87a5c

Please sign in to comment.