File tree Expand file tree Collapse file tree 3 files changed +14
-8
lines changed Expand file tree Collapse file tree 3 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -27,8 +27,9 @@ Returns an object with the following members:
27
27
28
28
- ` path ` : The absolute path to the temporary directory.
29
29
- ` writeFile(filePath, fileContents) ` : Write a file with path relative to the
30
- temporary directory. Any leading whitespace in the file contents is stripped.
31
- If the file starts with a shebang, it is given executable permissions.
30
+ temporary directory, returning the absolute path to the file. Any leading
31
+ whitespace in the file contents is stripped. If the file starts with a
32
+ shebang, it is given executable permissions.
32
33
33
34
``` js
34
35
import process from ' node:process'
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ import stripIndent from 'strip-indent'
24
24
*
25
25
* @return {Promise<{
26
26
* path: string,
27
- * writeFile(filePath: string, fileContents: string): Promise<void >
27
+ * writeFile(filePath: string, fileContents: string): Promise<string >
28
28
* }>} an object allowing manipulation of files within the directory.
29
29
*/
30
30
export default async function ( t , options ) {
@@ -49,6 +49,8 @@ export default async function (t, options) {
49
49
if ( contents . startsWith ( '#!' ) ) {
50
50
await fs . chmod ( absolutePath , 0o755 )
51
51
}
52
+
53
+ return absolutePath
52
54
} ,
53
55
}
54
56
}
Original file line number Diff line number Diff line change @@ -14,11 +14,14 @@ test.serial('creating a directory', async (t) => {
14
14
const stats = await fs . stat ( directory . path )
15
15
t . true ( stats . isDirectory ( ) )
16
16
17
- await directory . writeFile (
18
- 'file.txt' ,
19
- `
20
- Hello World!
21
- ` ,
17
+ t . is (
18
+ await directory . writeFile (
19
+ 'file.txt' ,
20
+ `
21
+ Hello World!
22
+ ` ,
23
+ ) ,
24
+ path . join ( directory . path , 'file.txt' ) ,
22
25
)
23
26
24
27
t . is (
You can’t perform that action at this time.
0 commit comments