Skip to content

Commit 4f1b1d3

Browse files
authored
Merge pull request #103 from wp-cli/97-conditional-feature
Only create a sample feature file when none exist
2 parents 1cbb3ad + 0898313 commit 4f1b1d3

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

features/scaffold-package-tests.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,13 @@ Feature: Scaffold the test suite for an existing package
104104
bash bin/test.sh
105105
"""
106106
And the community-command/.travis.yml file should not exist
107+
108+
Scenario: Don't scaffold features/load-wp-cli.feature when a feature file already exists
109+
When I run `wp scaffold package-tests community-command`
110+
And I run `mv community-command/features/load-wp-cli.feature community-command/features/command.feature`
111+
Then the community-command/features/load-wp-cli.feature file should not exist
112+
And the community-command/features/command.feature file should exist
113+
114+
When I run `wp scaffold package-tests community-command --force`
115+
Then the community-command/features/load-wp-cli.feature file should not exist
116+
And the community-command/features/command.feature file should exist

src/ScaffoldPackageCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,12 +502,16 @@ public function package_tests( $args, $assoc_args ) {
502502
'features/extra/no-mail.php' => $extra_dir,
503503
),
504504
$package_root => array(
505-
'templates/load-wp-cli.feature' => $features_dir,
506505
'bin/install-package-tests.sh' => $bin_dir,
507506
'bin/test.sh' => $bin_dir,
508507
),
509508
);
510509

510+
// Only create a sample feature file when none exist
511+
if ( ! glob( $features_dir . '/*.feature' ) ) {
512+
$copy_source[ $package_root ]['templates/load-wp-cli.feature'] = $features_dir;
513+
}
514+
511515
if ( 'travis' === $assoc_args['ci'] ) {
512516
$copy_source[ $package_root ]['.travis.yml'] = $package_dir;
513517
} else if ( 'circle' === $assoc_args['ci'] ) {

0 commit comments

Comments
 (0)