How to use the xdg-basedir.cache function in xdg-basedir

To help you get started, we’ve selected a few xdg-basedir examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebook / flipper / static / launcher.js View on Github external
const checkIsCycle = async () => {
  const dir = path.join(xdg.cache, 'flipper');
  const filePath = path.join(dir, 'last-launcher-run');
  // This isn't monotonically increasing, so there's a change we get time drift
  // between the checks, but the worst case here is that we do two roundtrips
  // before this check works.
  const rightNow = Date.now();

  let backThen;
  try {
    backThen = parseInt(await promisify(fs.readFile)(filePath), 10);
  } catch (e) {
    backThen = 0;
  }

  const delta = rightNow - backThen;
  await promisify(mkdirp)(dir);
  await promisify(fs.writeFile)(filePath, rightNow);
github bezoerb / generator-sf / generators / backend / symfony / index.js View on Github external
symfonyBase: function () {
    const source = 'https://github.com/symfony/symfony-standard/archive/v' + this.props.commit + '.zip';
    const dest = this.destinationRoot();
    const cache = path.join(xdgBasedir.cache, 'generator-sf');

    // Will be generated from the zip
    const dirname = 'symfony-standard-' + this.props.commit;
    const log = this.log.write();

    // Check cache first
    return fs.statAsync(path.join(cache, dirname))
      .catch(() => {
        log.info('Fetching %s ...', source)
          .info(chalk.yellow('This might take a few moments'));
        return download(source, cache, {extract: true});
      })
      .then(() => {
        return fs.copyAsync(path.join(cache, dirname) + '/', dest + '/.');
      });
  },
github yeoman / yeoman-remote / lib / index.js View on Github external
remote.cacheRoot = function cacheRoot() {
  return path.join(xdgBasedir.cache, 'node-yeoman-remote-cache');
};
github mradionov / tleaf / src / cache.js View on Github external
cache.path = function () {
  var basePath = basedir.cache || os.tempdir();
  var cachePath = path.join(basePath, C.CACHE_DIR_NAME, C.CACHE_FILE_NAME);
  return cachePath;
};

xdg-basedir

Get XDG Base Directory paths

MIT
Latest version published 3 years ago

Package Health Score

70 / 100
Full package analysis