summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-rmdir-recursive-sync-warns-on-file.js
blob: 96b9875416f9620da3b2d317767035ad61b97a62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'use strict';
const common = require('../common');
const tmpdir = require('../common/tmpdir');
const fs = require('fs');
const path = require('path');

tmpdir.refresh();

{
  // Should warn when trying to delete a file
  common.expectWarning(
    'DeprecationWarning',
    'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' +
    'will throw if path does not exist or is a file. Use fs.rm(path, ' +
    '{ recursive: true, force: true }) instead',
    'DEP0147'
  );
  const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt');
  fs.writeFileSync(filePath, '');
  fs.rmdirSync(filePath, { recursive: true });
}