Tabnine Logo For Javascript
unlinkSync
Code IndexAdd Tabnine to your IDE (free)

How to use
unlinkSync
function
in
fs

Best JavaScript code snippets using fs.unlinkSync(Showing top 15 results out of 1,836)

origin: lando/lando

/*
  * Toggle the secret toggle
  */
 clearTaskCaches() {
  if (fs.existsSync(process.landoTaskCacheFile)) fs.unlinkSync(process.landoTaskCacheFile);
  if (fs.existsSync(process.landoAppTaskCacheFile)) fs.unlinkSync(process.landoAppTaskCacheFile);
 }
origin: GoogleChromeLabs/ndb

/**
  * @param {string} fileURL
  */
 deleteFile(fileURL) {
  try {
   fs.unlinkSync(new URL(fileURL));
   return true;
  } catch (e) {
   return false;
  }
 }
origin: yagop/node-telegram-bot-api

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
    });
  });
 });
origin: stdlib/lib

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);
    });
   });
origin: reactide/reactide

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);
  }
 }
origin: gpujs/gpu.js

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));
});
origin: stdlib/lib

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);
}
origin: gpujs/gpu.js

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();
}
origin: lando/lando

/**
  * 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);
  }
 }
origin: sx1989827/DOClever

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);
  }
}
origin: lando/lando

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));
origin: moleculerjs/moleculer

    .then(hash => {
      expect(hash).toBe(originalHash);
      fs.unlinkSync(filename2);
    });
})));
origin: stdlib/lib

fs.unlinkSync(path.join(servicePath, 'source.json'));
origin: FaisalUmair/udemy-downloader-gui

error: function(error) {
 if (error.status == 401 || error.status == 403) {
  fs.unlinkSync(dl.filePath);
origin: esbenp/pdf-bot

function deleteQueue() {
 fs.unlinkSync(queuePath)
}
fsunlinkSync

JSDoc

Synchronous unlink(2) - delete a name and possibly the file it refers to.

Most used fs functions

  • readFileSync
    Synchronously reads the entire contents of a file.
  • existsSync
    Synchronously tests whether or not the given path exists by checking with the file system.
  • readFile
    Asynchronously reads the entire contents of a file.
  • readdirSync
    Synchronous readdir(3) - read a directory.
  • writeFile
    Asynchronously writes data to a file, replacing the file if it already exists.
  • createReadStream,
  • createWriteStream,
  • Stats.isDirectory,
  • statSync,
  • mkdirSync,
  • unlink,
  • ReadStream.pipe,
  • readdir,
  • Stats.isFile,
  • WriteStream.on,
  • stat,
  • ReadStream.on,
  • Stats.size

Popular in JavaScript

  • moment
    Parse, validate, manipulate, and display dates
  • aws-sdk
    AWS SDK for JavaScript
  • http
  • express
    Fast, unopinionated, minimalist web framework
  • crypto
  • cheerio
    Tiny, fast, and elegant implementation of core jQuery designed specifically for the server
  • bluebird
    Full featured Promises/A+ implementation with exceptionally good performance
  • lodash
    Lodash modular utilities.
  • mocha
    simple, flexible, fun test framework
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now