/* * Toggle the secret toggle */ clearTaskCaches() { if (fs.existsSync(process.landoTaskCacheFile)) fs.unlinkSync(process.landoTaskCacheFile); if (fs.existsSync(process.landoAppTaskCacheFile)) fs.unlinkSync(process.landoAppTaskCacheFile); }
/** * @param {string} fileURL */ deleteFile(fileURL) { try { fs.unlinkSync(new URL(fileURL)); return true; } catch (e) { return false; } }
describe('#downloadFile', function downloadFileSuite() { const downloadPath = os.tmpdir(); this.timeout(timeout); before(function before() { utils.handleRatelimit(bot, 'downloadFile', this); }); it('should download a file', function test() { return bot.downloadFile(FILE_ID, downloadPath) .then(filePath => { assert.ok(is.string(filePath)); assert.equal(path.dirname(filePath), downloadPath); assert.ok(fs.existsSync(filePath)); fs.unlinkSync(filePath); // Delete file after test }); }); });
tarball.on('close', () => { let buffer = fs.readFileSync(tmpPath); fs.unlinkSync(tmpPath); progress.log(`Package size: ${formatSize(buffer.byteLength)}`); progress.log(`Compressing ...`); zlib.gzip(buffer, (err, result) => { if (err) { return reject(err); } let t = new Date().valueOf() - start; progress.log(`Compressed size: ${formatSize(result.byteLength)}`); progress.log(`Compression: ${((result.byteLength / buffer.byteLength) * 100).toFixed(2)}%`); progress.log(`Pack complete, took ${t}ms!`); resolve(result); }); });
function recursivelyDelete(filePath) { //check if directory or file let stats = fs.statSync(filePath); //if file unlinkSync if (stats.isFile()) { fs.unlinkSync(filePath); } //if directory, readdir and call recursivelyDelete for each file else { let files = fs.readdirSync(filePath); files.forEach((file) => { recursivelyDelete(path.join(filePath, file)); }); fs.rmdirSync(filePath); } }
gulp.task('build-tests', () => { const folder = 'test'; const testFile = 'all.html'; try { fs.unlinkSync(`${folder}/${testFile}`); } catch (e) {} const rootPath = path.resolve(process.cwd(), folder); const warning = '<!-- the following list of javascript files is built automatically -->\n'; const files = readDirDeepSync(rootPath, { patterns: [ '**/*.js' ], ignore: [ '*.js' ] }) .map(file => file.replace(/^test\//, '')); return gulp.src(`${folder}/all-template.html`) .pipe(replace('{{test-files}}', warning + files.map(file => `<script type="module" src="${file}"></script>`).join('\n'))) .pipe(rename(testFile)) .pipe(gulp.dest(folder)); });
function rmdir(dir) { if (!fs.existsSync(dir)) { return null; } fs.readdirSync(dir).forEach(f => { let pathname = path.join(dir, f); if (!fs.existsSync(pathname)) { return fs.unlinkSync(pathname); } if (fs.statSync(pathname).isDirectory()) { return rmdir(pathname); } else { return fs.unlinkSync(pathname); } }); return fs.rmdirSync(dir); }
function toStringAsFileTest(mode) { const path = __dirname + `/to-string-as-file-${mode}.js`; const fs = require('fs'); if (fs.existsSync(path)) { fs.unlinkSync(path); } const gpu = new GPU({ mode }); const kernel = gpu.createKernel(function(v) { return v[this.thread.y][this.thread.x] + 1; }, { output: [1, 1] }); const a = [[1]]; const expected = kernel(a); assert.deepEqual(expected, [new Float32Array([2])]); const kernelAsString = kernel.toString(a); fs.writeFileSync(path, `module.exports = ${kernelAsString};`); const toStringAsFile = require(path); const restoredKernel = toStringAsFile({ context: kernel.context }); const result = restoredKernel(a); assert.deepEqual(result, expected); fs.unlinkSync(path); gpu.destroy(); }
/** * Manually remove an item from the cache. * * @since 3.0.0 * @alias lando.cache.remove * @param {String} key The name of the key to remove the data. * @example * // Remove the data stored with key mykey * lando.cache.remove('mykey'); */ remove(key) { // Try to get cache if (this.__del(key)) this.log.debug('Removed key %s from memcache.', key); else this.log.debug('Failed to remove key %s from memcache.', key); // Also remove file if applicable try { fs.unlinkSync(path.join(this.cacheDir, key)); } catch (e) { this.log.debug('No file cache with key %s', key); } }
var removeFolder=function (path) { var files = []; if(fs.existsSync(path)) { files = fs.readdirSync(path); files.forEach(function(file, index) { var curPath = path + "/" + file; if(fs.statSync(curPath).isDirectory()) { removeFolder(curPath); } else { fs.unlinkSync(curPath); } }); fs.rmdirSync(path); } }
this.updateUserConfig({channel: channel}); const updateFile = path.join(this.defaultConfig().userConfRoot, 'cache', 'updates'); if (fs.existsSync(updateFile)) fs.unlinkSync(updateFile); console.log(this.makeArt('releaseChannel', channel));
.then(hash => { expect(hash).toBe(originalHash); fs.unlinkSync(filename2); }); })));
fs.unlinkSync(path.join(servicePath, 'source.json'));
error: function(error) { if (error.status == 401 || error.status == 403) { fs.unlinkSync(dl.filePath);
function deleteQueue() { fs.unlinkSync(queuePath) }