File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ const fse = require ( '../..' )
4
+ const os = require ( 'os' )
5
+ const path = require ( 'path' )
6
+ const assert = require ( 'assert' )
7
+ const atLeastNode = require ( 'at-least-node' )
8
+
9
+ /* eslint-env mocha */
10
+
11
+ // Used for tests on Node 14.14.0+ only
12
+ const describeNode14 = atLeastNode ( '14.14.0' ) ? describe : describe . skip
13
+
14
+ describeNode14 ( 'fs.rm' , ( ) => {
15
+ let TEST_FILE
16
+
17
+ beforeEach ( done => {
18
+ TEST_FILE = path . join ( os . tmpdir ( ) , 'fs-extra' , 'fs-rm' )
19
+ fse . remove ( TEST_FILE , done )
20
+ } )
21
+
22
+ afterEach ( done => fse . remove ( TEST_FILE , done ) )
23
+
24
+ it ( 'supports promises' , ( ) => {
25
+ fse . writeFileSync ( TEST_FILE , 'hello' )
26
+ return fse . rm ( TEST_FILE ) . then ( ( ) => {
27
+ assert ( ! fse . pathExistsSync ( TEST_FILE ) )
28
+ } )
29
+ } )
30
+ } )
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ const api = [
31
31
'readlink' ,
32
32
'realpath' ,
33
33
'rename' ,
34
+ 'rm' ,
34
35
'rmdir' ,
35
36
'stat' ,
36
37
'symlink' ,
@@ -41,6 +42,7 @@ const api = [
41
42
] . filter ( key => {
42
43
// Some commands are not available on some systems. Ex:
43
44
// fs.opendir was added in Node.js v12.12.0
45
+ // fs.rm was added in Node.js v14.14.0
44
46
// fs.lchown is not available on at least some Linux
45
47
return typeof fs [ key ] === 'function'
46
48
} )
You can’t perform that action at this time.
0 commit comments