mirror of
https://github.com/nodejs/node.git
synced 2025-05-20 19:24:39 +00:00

This is a follow up to #35494 to add a deprecation warning when using recursive rmdir. This only warns if you are attempting to remove a file or a nonexistent path. PR-URL: https://github.com/nodejs/node/pull/35562 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
22 lines
635 B
JavaScript
22 lines
635 B
JavaScript
'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 });
|
|
}
|