11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ciconst fs = require('fs');
61cb0ef41Sopenharmony_ciconst path = require('path');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_citmpdir.refresh();
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciconst code = common.isWindows ? 'ENOENT' : 'ENOTDIR';
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ci{
131cb0ef41Sopenharmony_ci  const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt');
141cb0ef41Sopenharmony_ci  fs.writeFileSync(filePath, '');
151cb0ef41Sopenharmony_ci  assert.throws(() => fs.rmdirSync(filePath, { recursive: true }), { code });
161cb0ef41Sopenharmony_ci}
171cb0ef41Sopenharmony_ci{
181cb0ef41Sopenharmony_ci  const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt');
191cb0ef41Sopenharmony_ci  fs.writeFileSync(filePath, '');
201cb0ef41Sopenharmony_ci  fs.rmdir(filePath, { recursive: true }, common.mustCall((err) => {
211cb0ef41Sopenharmony_ci    assert.strictEqual(err.code, code);
221cb0ef41Sopenharmony_ci  }));
231cb0ef41Sopenharmony_ci}
241cb0ef41Sopenharmony_ci{
251cb0ef41Sopenharmony_ci  const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt');
261cb0ef41Sopenharmony_ci  fs.writeFileSync(filePath, '');
271cb0ef41Sopenharmony_ci  assert.rejects(() => fs.promises.rmdir(filePath, { recursive: true }),
281cb0ef41Sopenharmony_ci                 { code }).then(common.mustCall());
291cb0ef41Sopenharmony_ci}
30