function unlinkSync (fp) { try { fs.unlinkSync(fp) } catch (err) { if (err.code !== 'ENOENT') { process.emitWarning(err, 'AirtapWarning') } } }
const copy = (source, dest) => { if (source && fs.existsSync(source) && fs.existsSync(dest)) { fs.unlinkSync(dest); fs.createReadStream(source).pipe(fs.createWriteStream(dest)); return; } throw new Error("not match"); }
expect(exists).toBeTruthy(); if (exists) { fs.unlinkSync(fileName);
expect(qf[QueryFile.$query]).toBe(query); expect(qf.error).toBeUndefined(); fs.unlinkSync(sqlTemp); qf.prepare(); expect(qf.$query).toBeUndefined(); expect(qf[QueryFile.$query]).toBe(query); expect(qf.error).toBeUndefined(); fs.unlinkSync(sqlTemp); try { qf.prepare(true);
fs.unlinkSync(path.join(backupDir, file)); } catch(e) {} });
describe('cli', function () { it('#init', function (done) { this.timeout(60000); process.chdir(path.resolve(__dirname, './demo2')); let confDir = path.resolve(__dirname, './demo2/.dawn/'); let pipeFile = path.resolve(__dirname, './demo2/.dawn/pipe.yml'); let rcFile = path.resolve(__dirname, './demo2/.dawn/rc.yml'); if (fs.existsSync(pipeFile)) fs.unlinkSync(pipeFile); if (fs.existsSync(rcFile)) fs.unlinkSync(rcFile); if (fs.existsSync(confDir)) fs.rmdirSync(confDir); expect(fs.existsSync(pipeFile)).to.be.equal(false); cli.once('done', function () { expect(fs.existsSync(pipeFile)).to.be.equal(true); done(); }); cli.parse(['node', 'dn', 'init', '-t', 'unit-demo']); }); });
beforeEach(function() { try { fs.unlinkSync('.bowerrc') } catch (e) {} })
function cleanup (err, code) { if (err) console.error(err.stack) if (fs.existsSync(addonsDir)) { fs.readdirSync(addonsDir).forEach(function (addon) { let curPath = `${addonsDir}/${addon}` if (fs.statSync(curPath).isDirectory()) cleanup(curPath) else fs.unlinkSync(curPath) }) fs.rmdirSync(addonsDir) } process.exit(err ? 1 : code) }
const checkEnv = (currentEnv, callback) => { const env = dotEnv.parse(fs.readFileSync(`${process.cwd()}/${currentEnv}.env`)); callback(env); fs.unlinkSync(`${process.cwd()}/${currentEnv}.env`); }
test('should generate heap snapshot result file', async (t) => { // given const workerNodes = new WorkerNodes(fixture('echo-function-async'), { lazyStart: true }); await workerNodes.ready(); // when workerNodes.takeSnapshot(); await wait(1500); const result = fs.readdirSync(process.cwd()).find(name => name.includes('.heapsnapshot')); t.truthy(result); fs.unlinkSync(result); });
// delete a folder and the file inside it function remove(appDataPath = CERT_PATH) { if (fs.existsSync(appDataPath)) { fs.readdirSync(appDataPath) .forEach(file => fs.unlinkSync(path.join(appDataPath, file))) fs.rmdirSync(appDataPath) } }
someJob() { let failsLeft = fs.existsSync(tmpFile) ? parseInt(fs.readFileSync(tmpFile, 'utf8')) : 0; if (--failsLeft > 0) { fs.writeFileSync(tmpFile, String(failsLeft - 1)); return this.exitAlways(); } else { new Promise(resolve => fs.unlinkSync(tmpFile)).catch(error => error); return true; } }
/** * This destroys the index and deletes it from disk. * @api */ destroy() { this.close(); fs.unlinkSync(this.fileName); }
afterAll(function() { try { fs.unlinkSync('.bowerrc') } catch (e) {} })
test('should generate heap profiler result file', async (t) => { // given const workerNodes = new WorkerNodes(fixture('echo-function-async'), { lazyStart: true }); await workerNodes.ready(); // when workerNodes.profiler(200); await wait(500); const result = fs.readdirSync(process.cwd()).find(name => name.includes('.cpuprofile')); t.truthy(result, result); fs.unlinkSync(result); });