Merge branch 'master' into 3850-refactor-loading-order

This commit is contained in:
Alain Schlesser 2017-05-02 12:14:51 +02:00
commit 6eff23ff0b
4 changed files with 71 additions and 18 deletions

32
composer.lock generated
View file

@ -2306,16 +2306,16 @@
},
{
"name": "wp-cli/scaffold-command",
"version": "v1.0.1",
"version": "v1.0.3",
"source": {
"type": "git",
"url": "https://github.com/wp-cli/scaffold-command.git",
"reference": "9307ef70776042ea27c815b217d1ca76764f74b6"
"reference": "bc3559120fb86183df99a3b534fe201c6b199e1a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/wp-cli/scaffold-command/zipball/9307ef70776042ea27c815b217d1ca76764f74b6",
"reference": "9307ef70776042ea27c815b217d1ca76764f74b6",
"url": "https://api.github.com/repos/wp-cli/scaffold-command/zipball/bc3559120fb86183df99a3b534fe201c6b199e1a",
"reference": "bc3559120fb86183df99a3b534fe201c6b199e1a",
"shasum": ""
},
"require-dev": {
@ -2359,7 +2359,7 @@
],
"description": "Generate code for post types, taxonomies, plugins, child themes, etc.",
"homepage": "https://github.com/wp-cli/scaffold-command",
"time": "2017-04-17T11:42:40+00:00"
"time": "2017-04-30T14:34:58+00:00"
},
{
"name": "wp-cli/search-replace-command",
@ -2410,16 +2410,16 @@
},
{
"name": "wp-cli/server-command",
"version": "v1.0.3",
"version": "v1.0.4",
"source": {
"type": "git",
"url": "https://github.com/wp-cli/server-command.git",
"reference": "1e9a7c1067dbb67fc03379d9fdd509291021beb9"
"reference": "d180ea7cfe6b2061696fe02121ddc7d090f45f5a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/wp-cli/server-command/zipball/1e9a7c1067dbb67fc03379d9fdd509291021beb9",
"reference": "1e9a7c1067dbb67fc03379d9fdd509291021beb9",
"url": "https://api.github.com/repos/wp-cli/server-command/zipball/d180ea7cfe6b2061696fe02121ddc7d090f45f5a",
"reference": "d180ea7cfe6b2061696fe02121ddc7d090f45f5a",
"shasum": ""
},
"require": {
@ -2458,7 +2458,7 @@
],
"description": "Launch PHP's built-in web server for this specific WordPress installation.",
"homepage": "https://github.com/wp-cli/server-command",
"time": "2017-03-30T18:25:50+00:00"
"time": "2017-04-28T19:00:19+00:00"
},
{
"name": "wp-cli/shell-command",
@ -3190,12 +3190,12 @@
"source": {
"type": "git",
"url": "https://github.com/Roave/SecurityAdvisories.git",
"reference": "1196fb8f4bf78e53204838bbdda6f10547541f12"
"reference": "c5b0dbe69ca5bf8280b5486f5574e3de8c22f778"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/1196fb8f4bf78e53204838bbdda6f10547541f12",
"reference": "1196fb8f4bf78e53204838bbdda6f10547541f12",
"url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/c5b0dbe69ca5bf8280b5486f5574e3de8c22f778",
"reference": "c5b0dbe69ca5bf8280b5486f5574e3de8c22f778",
"shasum": ""
},
"conflict": {
@ -3220,8 +3220,8 @@
"doctrine/mongodb-odm-bundle": ">=2,<3.0.1",
"doctrine/orm": ">=2,<2.4.8|>=2.5,<2.5.1",
"dompdf/dompdf": ">=0.6,<0.6.2",
"drupal/core": ">=8,<8.2.7",
"drupal/drupal": ">=8,<8.2.7",
"drupal/core": ">=8,<8.2.8|>=8.3,<8.3.1",
"drupal/drupal": ">=8,<8.2.8|>=8.3,<8.3.1",
"firebase/php-jwt": "<2",
"friendsofsymfony/rest-bundle": ">=1.2,<1.2.2",
"friendsofsymfony/user-bundle": ">=1.2,<1.3.5",
@ -3317,7 +3317,7 @@
}
],
"description": "Prevents installation of composer packages with known security vulnerabilities: no API, simply require it",
"time": "2017-03-31T06:31:44+00:00"
"time": "2017-04-28T18:49:18+00:00"
}
],
"aliases": [

View file

@ -753,3 +753,53 @@ Feature: WP-CLI Commands
"""
Did you mean
"""

Scenario: Adding a command can be aborted through the hooks system
Given an empty directory
And a abort-add-command.php file:
"""
<?php
WP_CLI::add_hook( 'before_add_command:test-command-2', function ( $addition ) {
$addition->abort( 'Testing hooks.' );
} );

WP_CLI::add_command( 'test-command-1', function () {} );
WP_CLI::add_command( 'test-command-2', function () {} );
"""

When I run `wp --require=abort-add-command.php`
Then STDOUT should contain:
"""
test-command-1
"""
And STDOUT should not contain:
"""
test-command-2
"""

Scenario: Adding a command can depend on a previous command having been added before
Given an empty directory
And a add-dependent-command.php file:
"""
<?php
class TestCommand {
}

WP_CLI::add_hook( 'after_add_command:test-command', function () {
WP_CLI::add_command( 'test-command sub-command', function () {} );
} );

WP_CLI::add_command( 'test-command', 'TestCommand' );
"""

When I run `wp --require=add-dependent-command.php`
Then STDOUT should contain:
"""
test-command
"""

When I run `wp --require=add-dependent-command.php help test-command`
Then STDOUT should contain:
"""
sub-command
"""

View file

@ -1,5 +1,8 @@
<?php

// Store the path to the Phar early on for `Utils\phar-safe-path()` function.
define( 'WP_CLI_PHAR_PATH', getcwd() );

if ( file_exists( 'phar://wp-cli.phar/php/wp-cli.php' ) ) {
define( 'WP_CLI_ROOT', 'phar://wp-cli.phar' );
include WP_CLI_ROOT . '/php/wp-cli.php';

View file

@ -135,7 +135,7 @@ $finder
->files()
->ignoreVCS(true)
->ignoreDotFiles(false)
->in( WP_CLI_ROOT . '/vendor/wp-cli/config-command/templates')
->in( WP_CLI_VENDOR_DIR . '/wp-cli/config-command/templates')
;
foreach ( $finder as $file ) {
add_file( $phar, $file );
@ -146,7 +146,7 @@ $finder
->files()
->ignoreVCS(true)
->ignoreDotFiles(false)
->in( WP_CLI_ROOT . '/vendor/wp-cli/scaffold-command/templates')
->in( WP_CLI_VENDOR_DIR . '/wp-cli/scaffold-command/templates')
;
foreach ( $finder as $file ) {
add_file( $phar, $file );