Debian Codegraph @

fs2/test/empty-dir-sync.js

raw
1 "use strict";
2
3 const path = require("path")
4 , readdir = require("../readdir")
5 , mkdir = require("../mkdir")
6 , writeFile = require("../write-file")
7 , pg = path.resolve(__dirname, "__playground")
8 , rootPath = path.resolve(pg, "rmdir-sync")
9 , nested = path.resolve(rootPath, "one/two/three/dir")
10 , nested2 = path.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(path.resolve(nested, "../foo"), "bar"))
17 .then(() => {
18 try {
19 t(rootPath);
20 throw new Error("Unexpected");
21 } catch (error) {
22 if (!error.message.includes("ENOTEMPTY")) throw error;
23 a(error.message.includes("ENOTEMPTY"), true);
24 }
25
26 t(rootPath, { recursive: true });
27 return readdir(rootPath).then(content => { a.deep(content, []); });
28 });
29 };