Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 9 Examples of "xdg-basedir in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'xdg-basedir' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

import os from 'os'
import fse from 'fs-extra'
import low from 'lowdb'
import path from 'path'
import FileSync from 'lowdb/adapters/FileSync'
import xdgBasedir from 'xdg-basedir'

// 系统配置目录
const configDir = xdgBasedir.config || path.join(os.tmpdir(), '.config')
// cloudbase 配置目录
const cloudbaseConfigDir = path.join(configDir, '.cloudbase')

// 确保目录存在
fse.ensureDirSync(cloudbaseConfigDir)

export function getAuthDB() {
    const dbPath = path.join(cloudbaseConfigDir, 'auth.json')
    const adapter = new FileSync(dbPath)
    const db = low(adapter)
    return db
}
if (process.platform !== 'linux') {
		return Promise.reject(new Error('Only Linux systems are supported'));
	}

	if (!filePath) {
		return Promise.resolve(path.join(xdgBasedir.data, 'Trash'));
	}

	const [homeMountPoint, fileMountPoint] = await Promise.all([
		mountPoint(userHome),
		// Ignore errors in case `file` is a dangling symlink
		mountPoint(filePath).catch(() => {})
	]);

	if (!fileMountPoint || fileMountPoint === homeMountPoint) {
		return path.join(xdgBasedir.data, 'Trash');
	}

	return check(path.join(fileMountPoint, '.Trash'));
};
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);
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 + '/.');
      });
  },
get() {
    return xdgConfigOverride === false
      ? false
      : xdgConfigOverride || xdgBasedirCached.config;
  },
});
#!/usr/bin/env node
const fs = require('fs')
const path = require('path')
const xdg = require('xdg-basedir')

const config = process.argv[2] || path.join(xdg.config, 'statusbar')

if (!config) {
  console.log('Usage: statusbar ')
  process.exit(1)
}

const configPath = path.resolve(process.cwd(), config)
let configModule
try {
  configModule = require.resolve(configPath)
} catch (err) {
  console.error(`Could not find config file "${config}"`)
  process.exit(1)
}

global.bar = require('.')()
const os = require('os');
const mkdirp = require('mkdirp');
const path = require('path');
const fs = require('fs');
const splitFile = require('split-file');
const async = require('async');
const xdgBasedir = require('xdg-basedir');
const md5File = require('md5-file');
const request = require('request');
const send = require('send');

const configDir = path.join(xdgBasedir.config || path.join(os.tmpdir(), '.config'), 'freeshare');
const storeDir = path.join(xdgBasedir.data || path.join(os.tmpdir(), '.local'), 'free-share-store');

let instance = null;

class FileStore {
    constructor() {
        if (!instance) {
            instance = this;
        }

        return instance;
    }

    init() {
        this.fileMap = new Map();

        return new Promise((resolve, reject) => {
function exportToFile (exportFilepath, printToConsole) {
  var fs = require('fs');
  var xdgBasedir = require('xdg-basedir');
  var logSymbols = require('log-symbols');

  var expensesFilepath = xdgBasedir.data + '/wallet/expenses.csv';
  var contents = fs.readFileSync(expensesFilepath);

  var prettyDate = require('date-format').asString('yyyy-MM-dd', new Date());

  var defaultExportFilepath = xdgBasedir.data +
    '/wallet/exported/export-' +
    prettyDate + '.csv';

  exportFilepath = exportFilepath || defaultExportFilepath;

  fs.writeFileSync(exportFilepath, 'Date,Remarks,Category,Credit,Debit\n');
  fs.appendFileSync(exportFilepath, contents);

  if (printToConsole === undefined) {
    console.log();
    console.log(logSymbols.success + ' Your file can be found at :-');
'use strict';
var path = require('path');
var fs = require('graceful-fs');
var osenv = require('osenv');
var assign = require('object-assign');
var mkdirp = require('mkdirp');
var uuid = require('uuid');
var xdgBasedir = require('xdg-basedir');
var osTmpdir = require('os-tmpdir');
var writeFileAtomic = require('write-file-atomic');
var dotProp = require('dot-prop');

var user = (osenv.user() || uuid.v4()).replace(/\\/g, '');
var configDir = xdgBasedir.config || path.join(osTmpdir(), user, '.config');
var permissionError = 'You don\'t have access to this file.';
var defaultPathMode = parseInt('0700', 8);
var writeFileOptions = {mode: parseInt('0600', 8)};

function Configstore(id, defaults, opts) {
	opts = opts || {};

	var pathPrefix = opts.globalConfigPath ?
		path.join(id, 'config.json') :
		path.join('configstore', id + '.json');

	this.path = path.join(configDir, pathPrefix);

	this.all = assign({}, defaults || {}, this.all || {});
}

Is your System Free of Underlying Vulnerabilities?
Find Out Now