.then(x => { // parent dir expect(x.isDirectory).to.be.true; expect(x.children.length).to.be.equal(2); expect(x.name).to.be.equal(path.basename(parent)); expect(x.path).to.be.equal(parent); // child dir const d = x.children.find(xx => xx.path === childDir); expect(d.isDirectory).to.be.true; expect(d.children.length).to.be.equal(1); // file parent dir const f = x.children.find(xx => xx.path === fileParent); expect(f.isDirectory).to.be.false; expect(f.children).to.be.undefined; // file child dir const f2 = d.children.find(xx => xx.path === fileChildDir); expect(f2.isDirectory).to.be.false; expect(f2.children).to.be.undefined; fs.unlinkSync(fileChildDir); fs.unlinkSync(fileParent); fs.rmdirSync(childDir); fs.rmdirSync(parent); done(); })
Promise.then(function(fileLocations: File.AbsoluteFilePath[]) { expect(fileLocations).toContain({ absolutePath: __dirname + '/tmp/test.value', }); expect(fileLocations).toContain({ absolutePath: __dirname + '/tmp/test2.value', }); expect(fileLocations).toContain({ absolutePath: __dirname + '/tmp/tmp2/test.value', }); expect(fileLocations).toContain({ absolutePath: __dirname + '/tmp/tmp3/test.value', }); expect(fileLocations).toContain({ absolutePath: __dirname + '/tmp/tmp3/tmp4/test2.value', }); fs.unlinkSync(__dirname + '/tmp/tmp3/tmp4/test2.value'); fs.rmdirSync(__dirname + '/tmp/tmp3/tmp4'); fs.unlinkSync(__dirname + '/tmp/tmp3/test.value'); fs.rmdirSync(__dirname + '/tmp/tmp3'); fs.unlinkSync(__dirname + '/tmp/tmp2/test2.enum'); fs.unlinkSync(__dirname + '/tmp/tmp2/test.value'); fs.rmdirSync(__dirname + '/tmp/tmp2'); fs.unlinkSync(__dirname + '/tmp/test2.value'); fs.unlinkSync(__dirname + '/tmp/test.value'); fs.rmdirSync(__dirname + '/tmp'); finished(); }, future);
.then((result) => { t.ok(result.exists, 'file exists') t.equal(result.contentType, 'application/octet-stream', 'file has fall-back content type') // try without the gaia metadata directory fs.rmdirSync(Path.join(storageDir, '.gaia-metadata/12345/foo')) fs.rmdirSync(Path.join(storageDir, '.gaia-metadata/12345')) fs.rmdirSync(Path.join(storageDir, '.gaia-metadata')) return server.handleGet('12345', 'foo/bar.txt') })
.then((result) => { t.ok(result.exists, 'file exists') t.equal(result.contentType, 'application/octet-stream', 'file has fall-back content type') // blow away the file fs.unlinkSync(Path.join(storageDir, '12345/foo/bar.txt')) fs.rmdirSync(Path.join(storageDir, '12345/foo')) fs.rmdirSync(Path.join(storageDir, '12345')) return server.handleGet('12345', 'foo/bar.txt') })
it('should not throw on folder create if overwrite is true', async () => { let filepath = path.join(__dirname, 'bar/') await workspace.createFile(filepath) await workspace.createFile(filepath, { overwrite: true }) expect(fs.existsSync(filepath)).toBe(true) fs.rmdirSync(filepath) })
export function drop(target: string, log: Function = function () { }) { let rootEntry = scan_entry(path.resolve(target)) switch (rootEntry.type) { case "null": return case "file": throw Error(`cannot drop directory ${rootEntry.fullname} because its a file.`) case "directory": let stack = drop_stack(rootEntry.fullname) while (stack.length > 0) { let dropEntry = stack.pop() switch (dropEntry.type) { case "null": break; case "directory": log(`dropping: ${dropEntry.fullname}`); fs.rmdirSync(dropEntry.fullname); break; case "file": log(`dropping: ${dropEntry.fullname}`); fs.unlinkSync(dropEntry.fullname); break; } } } }
setUp: (callback: NodeUnit.ICallbackFunction): void => { let paths: string[][] = [ ['report', 'checkstyle.xml'], ['release', '1', 'checkstyle.xml'], ]; let p: number; let fileName: string; for (p = 0; p < paths.length; p++) { while (paths[p].length) { fileName = Path.join(context.fixturesDir, ...paths[p]); if (FS.existsSync(fileName)) { if (FS.statSync(fileName).isDirectory()) { FS.rmdirSync(fileName); } else { if (FS.statSync(fileName).isFile()) { FS.unlinkSync(fileName); } } } paths[p].pop(); } } if (!FS.existsSync(context.fixturesDir)) { mkDir.sync(context.fixturesDir); } callback(); },
export function remove(path:string) { var isFile = FS.statSync(path).isFile(); if (isFile) FS.unlinkSync(path); else FS.rmdirSync(path); }
}, (error, stdout, stderr) => { console.log("importing " + testCaseName + " ..."); console.log(cmd); if (error) { console.log("importing " + testCaseName + " ..."); console.log(cmd); console.log("==> error " + JSON.stringify(error)); console.log("==> stdout " + String(stdout)); console.log("==> stderr " + String(stderr)); console.log("\r\n"); return; } // copy generated file to output location var outputFilePath = path.join(testDirectoryPath, "iocapture0.json"); var testCasePath = path.join(rwcTestPath, "DefinitelyTyped_" + testCaseName + ".json"); copyFileSync(outputFilePath, testCasePath); //console.log("output generated at: " + outputFilePath); if (!fs.existsSync(testCasePath)) { throw new Error("could not find test case at: " + testCasePath); } else { fs.unlinkSync(outputFilePath); fs.rmdirSync(testDirectoryPath); //console.log("testcase generated at: " + testCasePath); //console.log("Done."); } //console.log("\r\n"); })
afterAll(() => { try { fs.unlinkSync(fileName); fs.rmdirSync(tmpDir); } catch (_) { } });