before(function () { if (windowsTestLink) { enfsmkdirp.mkdirpSync(nodePath.join(tmpPath, "src", "default")); enFs.writeFileSync(nodePath.join(tmpPath, "src", "default", "file"), "contents"); enFs.symlinkSync(nodePath.join(tmpPath, "src", "default", "file"), nodePath.join(tmpPath, "src", "default", "fileLink"), "file"); enFs.mkdirSync(nodePath.join(tmpPath, "src", "default", "dir")); enFs.writeFileSync(nodePath.join(tmpPath, "src", "default", "dirFile"), "contents"); enFs.symlinkSync(nodePath.join(tmpPath, "src", "default", "dir"), nodePath.join(tmpPath, "src", "default", "dirFileLink"), "dir"); enfsmkdirp.mkdirpSync(nodePath.join(tmpPath, "src", "deref")); enFs.writeFileSync(nodePath.join(tmpPath, "src", "deref", "file"), "contents"); enFs.symlinkSync(nodePath.join(tmpPath, "src", "deref", "file"), nodePath.join(tmpPath, "src", "deref", "fileLink"), "file"); enFs.mkdirSync(nodePath.join(tmpPath, "src", "deref", "dir")); enFs.writeFileSync(nodePath.join(tmpPath, "src", "deref", "dir", "dirFile"), "contents"); enFs.symlinkSync(nodePath.join(tmpPath, "src", "deref", "dir"), nodePath.join(tmpPath, "src", "deref", "dirFileLink"), "dir"); } });
beforeEach(function () { enFs.writeFileSync(nodePath.join(tmpPath, "foo.txt"), "foo\n"); ensure.ensureDirSync(nodePath.join(tmpPath, "empty-dir")); ensure.ensureFileSync(nodePath.join(tmpPath, "dir-foo", "foo.txt"), {data: "dir-foo\n"}); ensure.ensureFileSync(nodePath.join(tmpPath, "dir-bar", "bar.txt"), {data: "dir-bar\n"}); ensure.ensureDirSync(nodePath.join(tmpPath, "real-alpha", "real-beta", "real-gamma")); });
function createFile(name, mode, owner) { enFs.writeFileSync(name, ""); enFs.chmodSync(name, mode); enFs.chownSync(name, process.getuid(), owner); const stat = enFs.lstatSync(name); (stat.mode - S_IFREG).should.be.equal(mode); return stat; }
beforeEach(function() { enfsmkdirp.mkdirpSync(src); enfsmkdirp.mkdirpSync(out); enfsmkdirp.mkdirpSync(srcOut); enfsmkdirp.mkdirpSync(doubleSrcOut); enfsmkdirp.mkdirpSync(doubleSrcMiddleOut); enFs.writeFileSync(srcFile, "data", "utf8"); });
ensureDir(nodePath.dirname(file), function(errDir) { (errDir === null).should.be.equal(true); enFs.writeFileSync(file, "hello world"); ensureFile(file, function(err) { (err === null).should.be.equal(true); enFs.readFileSync(file, "utf8").should.be.equal("hello world"); done(); }); });
before(function () { enfsmkdirp.mkdirpSync(tmpPath); process.chdir(tmpPath); if (isWindows) { enFs.writeFileSync(nodePath.join(tmpPath, "windowsTest", "")); try { enFs.symlinkSync(nodePath.join(tmpPath, "windowsTestLink"), nodePath.join(tmpPath, "windowsTest"), "file"); } catch (err) { if (err.code === "EPERM") { console.warn("Not running tests with symlink in windows, don't have permissions, \nif you wan't to test this try running as administrator."); windowsTestLink = false; } } } enFs.writeFileSync(nodePath.join(tmpPath, "TEST_enfscopy_src"), nodeCrypto.randomBytes(SIZE)); enFs.writeFileSync(nodePath.join(tmpPath, "file.bin"), ""); enFs.writeFileSync(nodePath.join(tmpPath, "file.css"), ""); enFs.writeFileSync(nodePath.join(tmpPath, "file1.bin"), ""); enFs.writeFileSync(nodePath.join(tmpPath, "file.txt"), "did it copy?\n", "utf8"); enFs.mkdirSync(nodePath.join(tmpPath, "srca")); for (let i = 0; i < FILES; i++) { enFs.writeFileSync(nodePath.join(tmpPath, "srca", i.toString()), nodeCrypto.randomBytes(SIZE)); } enFs.mkdirSync(nodePath.join(tmpPath, "srca", "subdir")); for (let i = 0; i < FILES; i++) { enFs.writeFileSync(nodePath.join(tmpPath, "srca", "subdir", i.toString()), nodeCrypto.randomBytes(SIZE)); } enFs.mkdirSync(nodePath.join(tmpPath, "data")); enFs.writeFileSync(nodePath.join(tmpPath, "data", "f1.txt"), "file1"); enFs.writeFileSync(nodePath.join(tmpPath, "data", "f2.txt"), "file2"); enFs.writeFileSync(nodePath.join(tmpPath, "identicalFile"), "some data"); enFs.writeFileSync(nodePath.join(tmpPath, "identicalFile1"), "some data"); if (windowsTestLink) { enFs.symlinkSync(nodePath.join(tmpPath, "identicalFile"), nodePath.join(tmpPath, "testLink"), "file"); enFs.symlinkSync(nodePath.join(tmpPath, "identicalFile1"), nodePath.join(tmpPath, "testLink1"), "file"); } });