Skip to content

Commit 7fb6be8

Browse files
committed
Add an item in extras to force unix style directory separators
1 parent bcb5d58 commit 7fb6be8

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

src/lkwdwrd/Composer/MULoaderPlugin.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ public function dumpRequireFile() {
134134

135135
// Find the relative path from the mu-plugins dir to the mu-loader file.
136136
$muPath = $this->resolveMURelPath( $muRelPath );
137-
$loadFile = dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'mu-loader.php';
138-
$toLoader = DIRECTORY_SEPARATOR . Util\rel_path( $muPath, $loadFile );
137+
$ds = $this->getDirectorySeparator();
138+
$loadFile = dirname( __DIR__ ) . $ds . 'mu-loader.php';
139+
$toLoader = $ds . Util\rel_path( $muPath, $loadFile, $ds );
139140

140141
// Write the boostrapping PHP file.
141142
if ( !file_exists( $muPath ) ) {
@@ -194,4 +195,21 @@ protected function resolveMURelPath( $relpath ) {
194195
// Return the abosolute path.
195196
return $basepath . $relpath;
196197
}
198+
199+
/**
200+
* Get the directory separator to use for the generatoed loader
201+
*
202+
* This defaults to the DIRECTORY_SEPARATOR constant, but can be overridden in
203+
* the composer.json extra section with "force-unix-separator" set to true.
204+
*
205+
* @return string The directory separator character to use
206+
*/
207+
protected function getDirectorySeparator() {
208+
$separator = DIRECTORY_SEPARATOR;
209+
if ( ! empty( $this->extras['force-unix-separator'] ) ) {
210+
$separator = '/';
211+
}
212+
213+
return $separator;
214+
}
197215
}

0 commit comments

Comments
 (0)