Skip to content

Commit 9da6770

Browse files
authored
Merge pull request #79 from wp-cli/refresh-scaffold-files
Update scaffolded files
2 parents cb493ac + 9810dcd commit 9da6770

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

bin/test.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ then
88
phpunit
99
fi
1010

11+
if [ $WP_VERSION = "latest" ]; then
12+
export WP_VERSION=$(curl -s https://api.wordpress.org/core/version-check/1.7/ | jq -r ".offers[0].current")
13+
fi
14+
1115
# Run the functional tests
1216
BEHAT_TAGS=$(php utils/behat-tags.php)
1317
behat --format progress $BEHAT_TAGS --strict

features/bootstrap/utils.php

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function extract_from_phar( $path ) {
2424

2525
$fname = basename( $path );
2626

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

2929
copy( $path, $tmp_path );
3030

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

358360
check_proc_available( 'launch_editor_for_input' );
359361

360362
$tmpdir = get_temp_dir();
361363

362364
do {
363-
$tmpfile = basename( $filename );
365+
$tmpfile = basename( $title );
364366
$tmpfile = preg_replace( '|\.[^.]*$|', '', $tmpfile );
365367
$tmpfile .= '-' . substr( md5( mt_rand() ), 0, 6 );
366-
$tmpfile = $tmpdir . $tmpfile . '.tmp';
368+
$tmpfile = $tmpdir . $tmpfile . '.' . $ext;
367369
$fp = fopen( $tmpfile, 'xb' );
368370
if ( ! $fp && is_writable( $tmpdir ) && file_exists( $tmpfile ) ) {
369371
$tmpfile = '';
@@ -772,6 +774,31 @@ function trailingslashit( $string ) {
772774
return rtrim( $string, '/\\' ) . '/';
773775
}
774776

777+
/**
778+
* Normalize a filesystem path.
779+
*
780+
* On Windows systems, replaces backslashes with forward slashes
781+
* and forces upper-case drive letters.
782+
* Allows for two leading slashes for Windows network shares, but
783+
* ensures that all other duplicate slashes are reduced to a single one.
784+
* Ensures upper-case drive letters on Windows systems.
785+
*
786+
* @access public
787+
* @category System
788+
*
789+
* @param string $path Path to normalize.
790+
* @return string Normalized path.
791+
*/
792+
function normalize_path( $path ) {
793+
$path = str_replace( '\\', '/', $path );
794+
$path = preg_replace( '|(?<=.)/+|', '/', $path );
795+
if ( ':' === substr( $path, 1, 1 ) ) {
796+
$path = ucfirst( $path );
797+
}
798+
return $path;
799+
}
800+
801+
775802
/**
776803
* Convert Windows EOLs to *nix.
777804
*
@@ -1307,6 +1334,7 @@ function get_php_binary() {
13071334

13081335
// Available since PHP 5.4.
13091336
if ( defined( 'PHP_BINARY' ) ) {
1337+
// @codingStandardsIgnoreLine
13101338
return PHP_BINARY;
13111339
}
13121340

0 commit comments

Comments
 (0)