Skip to content

Commit

Permalink
Merge pull request wp-cli#37 from wp-cli/refresh-scaffold-files
Browse files Browse the repository at this point in the history
Update scaffolded files
  • Loading branch information
schlessera authored Apr 20, 2018
2 parents d85e5a4 + 909f35f commit 776d33a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules/
vendor/
*.zip
*.tar.gz
composer.lock
4 changes: 4 additions & 0 deletions bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ then
phpunit
fi

if [ $WP_VERSION = "latest" ]; then
export WP_VERSION=$(curl -s https://api.wordpress.org/core/version-check/1.7/ | jq -r ".offers[0].current")
fi

# Run the functional tests
BEHAT_TAGS=$(php utils/behat-tags.php)
behat --format progress $BEHAT_TAGS --strict
36 changes: 32 additions & 4 deletions features/bootstrap/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function extract_from_phar( $path ) {

$fname = basename( $path );

$tmp_path = get_temp_dir() . "wp-cli-$fname";
$tmp_path = get_temp_dir() . uniqid( 'wp-cli-extract-from-phar-', true ) . "-$fname";

copy( $path, $tmp_path );

Expand Down Expand Up @@ -351,19 +351,21 @@ function pick_fields( $item, $fields ) {
* @category Input
*
* @param string $content Some form of text to edit (e.g. post content)
* @param string $title Title to display in the editor.
* @param string $ext Extension to use with the temp file.
* @return string|bool Edited text, if file is saved from editor; false, if no change to file.
*/
function launch_editor_for_input( $input, $filename = 'WP-CLI' ) {
function launch_editor_for_input( $input, $title = 'WP-CLI', $ext = 'tmp' ) {

check_proc_available( 'launch_editor_for_input' );

$tmpdir = get_temp_dir();

do {
$tmpfile = basename( $filename );
$tmpfile = basename( $title );
$tmpfile = preg_replace( '|\.[^.]*$|', '', $tmpfile );
$tmpfile .= '-' . substr( md5( mt_rand() ), 0, 6 );
$tmpfile = $tmpdir . $tmpfile . '.tmp';
$tmpfile = $tmpdir . $tmpfile . '.' . $ext;
$fp = fopen( $tmpfile, 'xb' );
if ( ! $fp && is_writable( $tmpdir ) && file_exists( $tmpfile ) ) {
$tmpfile = '';
Expand Down Expand Up @@ -772,6 +774,31 @@ function trailingslashit( $string ) {
return rtrim( $string, '/\\' ) . '/';
}

/**
* Normalize a filesystem path.
*
* On Windows systems, replaces backslashes with forward slashes
* and forces upper-case drive letters.
* Allows for two leading slashes for Windows network shares, but
* ensures that all other duplicate slashes are reduced to a single one.
* Ensures upper-case drive letters on Windows systems.
*
* @access public
* @category System
*
* @param string $path Path to normalize.
* @return string Normalized path.
*/
function normalize_path( $path ) {
$path = str_replace( '\\', '/', $path );
$path = preg_replace( '|(?<=.)/+|', '/', $path );
if ( ':' === substr( $path, 1, 1 ) ) {
$path = ucfirst( $path );
}
return $path;
}


/**
* Convert Windows EOLs to *nix.
*
Expand Down Expand Up @@ -1307,6 +1334,7 @@ function get_php_binary() {

// Available since PHP 5.4.
if ( defined( 'PHP_BINARY' ) ) {
// @codingStandardsIgnoreLine
return PHP_BINARY;
}

Expand Down

0 comments on commit 776d33a

Please sign in to comment.