Skip to content

Commit 5e8e97c

Browse files
Use a tmp directory for WP-CLI tests
1 parent a241c2d commit 5e8e97c

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import path from 'path';
22
import getWpNowPath from './get-wp-now-path';
3+
import getWpCliTmpPath from './get-wp-cli-tmp-path';
34

45
/**
56
* The path for wp-cli phar file within the WP Now folder.
@@ -8,5 +9,5 @@ export default function getWpCliPath() {
89
if (process.env.NODE_ENV !== 'test') {
910
return path.join(getWpNowPath(), 'wp-cli.phar');
1011
}
11-
return path.resolve('./wp-cli.phar');
12+
return getWpCliTmpPath();
1213
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import path from 'path';
2+
import os from 'os';
3+
4+
/**
5+
* The full path to the hidden WP-CLI folder in the user's tmp directory.
6+
*/
7+
export default function getWpCliTmpPath() {
8+
const tmpDirectory = os.tmpdir();
9+
10+
return path.join(tmpDirectory, `wp-now-tests-wp-cli-hidden-folder`);
11+
}

packages/wp-now/src/tests/wp-now.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import {
1717
import os from 'os';
1818
import crypto from 'crypto';
1919
import getWpNowTmpPath from '../get-wp-now-tmp-path';
20+
import getWpCliTmpPath from '../get-wp-cli-tmp-path';
2021
import { executeWPCli } from '../execute-wp-cli';
21-
import getWpCliPath from '../get-wp-cli-path';
2222

2323
const exampleDir = __dirname + '/mode-examples';
2424

@@ -539,7 +539,7 @@ describe('wp-cli command', () => {
539539
});
540540

541541
afterAll(() => {
542-
fs.removeSync(getWpCliPath());
542+
fs.removeSync(getWpCliTmpPath());
543543
});
544544

545545
/**

0 commit comments

Comments
 (0)