Skip to content

Commit

Permalink
Autoload: bug fix
Browse files Browse the repository at this point in the history
Composer project based install wasn't sufficiently supported. This small change fixes that.

Fixes 184
  • Loading branch information
jrfnl committed Oct 21, 2018
1 parent 50ba5f7 commit 34b6451
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@
* Load the WPCS autoload file.
*/
// Get the WPCS dir from an environment variable.
$wpcsDir = getenv( 'WPCS_DIR' );
$composerWPCSPath = $projectRoot . 'vendor' . $ds . 'wp-coding-standards' . $ds . 'wpcs';
$wpcsDir = getenv( 'WPCS_DIR' );
$composerWPCSPath = $projectRoot . 'vendor' . $ds . 'wp-coding-standards' . $ds . 'wpcs';
$composerWPCSPathProject = $projectRoot . '..' . $ds . '..' . $ds . 'wp-coding-standards' . $ds . 'wpcs';

if ( false === $wpcsDir && is_dir( $composerWPCSPath ) ) {
// WPCS installed via Composer.
$wpcsDir = $composerWPCSPath;
} elseif ( false === $wpcsDir && is_dir( $composerWPCSPathProject ) ) {
// TRTCS + WPCS installed via Composer.
$wpcsDir = $composerWPCSPathProject;
} elseif ( false !== $wpcsDir ) {
/*
* WPCS in a custom directory [1].
Expand Down Expand Up @@ -66,4 +70,4 @@
}

// Clean up.
unset( $ds, $projectRoot, $wpcsDir, $composerWPCSPath, $wpcsPath );
unset( $ds, $projectRoot, $wpcsDir, $composerWPCSPath, $composerWPCSPathProject, $wpcsPath );

0 comments on commit 34b6451

Please sign in to comment.