Debian Codegraph @

fs2/test/rmdir-sync.js

raw
1 "use strict";
2
3 const { resolve } = require("path")
4 , lstat = require("../lstat")
5 , mkdir = require("../mkdir")
6 , writeFile = require("../write-file")
7 , pg = resolve(__dirname, "__playground")
8 , rootPath = resolve(pg, "rmdir-sync")
9 , nested = resolve(rootPath, "one/two/three/dir")
10 , nested2 = resolve(rootPath, "one/four/five/six");
11
12 module.exports = function (t, a) {
13 return Promise.all([
14 mkdir(nested, { intermediate: true }), mkdir(nested2, { intermediate: true })
15 ])
16 .then(() => writeFile(resolve(nested, "../foo"), "bar"))
17 .then(() => {
18 try {
19 t(rootPath);
20 throw new Error("Unexpected");
21 } catch (error) {
22 a(error.code, "ENOTEMPTY", "Default on not empty");
23 }
24
25 t(rootPath, { recursive: true, force: true });
26 return lstat(rootPath).then(a.never, err => {
27 a(err.code, "ENOENT", "Recursive and forced");
28 });
29 });
30 };