Skip to content

Commit 8735e26

Browse files
authored
Merge pull request #127 from wp-cli/119-realpath
Convert '~/' when supplied in `$package_dir`
2 parents fd1bf6b + 6b0365c commit 8735e26

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

features/scaffold-package.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,13 @@ Feature: Scaffold WP-CLI commands
220220
"""
221221
Success: Uninstalled package.
222222
"""
223+
224+
Scenario: Use tilde for HOME in package directory path
225+
Given an empty directory
226+
227+
When I run `wp scaffold package bar/foo --dir=~/foo --force --skip-tests --skip-readme`
228+
Then STDOUT should contain:
229+
"""
230+
Success: Package installed.
231+
"""
232+
And the /tmp/wp-cli-home/foo directory should exist

src/ScaffoldPackageCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ public function package( $args, $assoc_args ) {
7979
$package_dir = WP_CLI::get_runner()->get_packages_dir_path() . 'local/' . $assoc_args['name'];
8080
}
8181

82+
if ( '~/' === substr( $package_dir, 0, 2 ) && ( $home = getenv( 'HOME' ) ) ) {
83+
$package_dir = $home . substr( $package_dir, 1 );
84+
}
85+
8286
if ( empty( $assoc_args['homepage'] ) ) {
8387
$assoc_args['homepage'] = 'https://github.com/' . $assoc_args['name'];
8488
}

0 commit comments

Comments
 (0)