File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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 = [
3131 'readlink' ,
3232 'realpath' ,
3333 'rename' ,
34+ 'rm' ,
3435 'rmdir' ,
3536 'stat' ,
3637 'symlink' ,
@@ -41,6 +42,7 @@ const api = [
4142] . filter ( key => {
4243 // Some commands are not available on some systems. Ex:
4344 // fs.opendir was added in Node.js v12.12.0
45+ // fs.rm was added in Node.js v14.14.0
4446 // fs.lchown is not available on at least some Linux
4547 return typeof fs [ key ] === 'function'
4648} )
You can’t perform that action at this time.
0 commit comments