How to use the xdg-basedir.data 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 kevva / xdg-trashdir / index.js View on Github external
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'));
};
github psychokinesis-dev / free-share / app / file-store.js View on Github external
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) => {
github icyflame / terminal-wallet / export-module.js View on Github external
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 :-');
github icyflame / terminal-wallet / file-module.js View on Github external
function writeExpense (expenseObjectParam) {
  var xdgBasedir = require('xdg-basedir');
  var expensesFilepath = xdgBasedir.data + '/wallet/expenses.csv';
  var fs = require('fs');
  var logSymbols = require('log-symbols');
  var prettyDate = require('date-format').asString('yyyy-MM-dd', new Date());

  var record = [
    prettyDate,
    expenseObjectParam.reason,
    expenseObjectParam.category,
    expenseObjectParam.credit,
    expenseObjectParam.debit
  ].join(delimiter);

  fs.appendFile(expensesFilepath, record + '\n', function (err) {
    if (err) {
      throw (err);
    } else {
github icyflame / terminal-wallet / stats-module.js View on Github external
function getBalance (cb) {
  var expensesFilepath = xdgBasedir.data + '/wallet/expenses.csv';
  var stream = fs.createReadStream(expensesFilepath);

  var totalCredit = 0.0;
  var totalDebit = 0.0;

  csv
    .fromStream(stream)
    .transform(function (data) {
      return {
        'date': data[0],
        'reason': data[1],
        'category': data[2],
        'credit': numberIsNan(parseFloat(data[3])) ? 0.0 : parseFloat(data[3]),
        'debit': numberIsNan(parseFloat(data[4])) ? 0.0 : parseFloat(data[4])
      };
    })
github icyflame / terminal-wallet / setup-files.js View on Github external
function createFileIfDoesNotExist (filepath) {
  var touch = require('touch');
  var xdg = require('xdg-basedir');
  var mkdirp = require('mkdirp');

  filepath = filepath || (xdg.data + '/wallet/expenses.csv');

  mkdirp.sync(xdg.data + '/wallet/exported');
  mkdirp.sync(xdg.data + '/wallet/closed');
  touch.sync(xdg.data + '/wallet/expenses.csv');
}
github icyflame / cli-cube-timer / constants.js View on Github external
var xdg = require('xdg-basedir');
exports.LOCAL_FILE_PATH = xdg.data + '/cube/times.csv';
exports.PUSHED_FILE_PATH = xdg.data + '/cube/pushed.csv';
github icyflame / cli-cube-timer / constants.js View on Github external
var xdg = require('xdg-basedir');
exports.LOCAL_FILE_PATH = xdg.data + '/cube/times.csv';
exports.PUSHED_FILE_PATH = xdg.data + '/cube/pushed.csv';
github kevva / xdg-trashdir / index.js View on Github external
const stickyBitMode = 17407;

	try {
		const stats = await fs.lstat(filePath);

		if (stats.isSymbolicLink() || stats.mode !== stickyBitMode) {
			return topuid;
		}

		return path.join(filePath, String(process.getuid()));
	} catch (error) {
		if (error.code === 'ENOENT') {
			return topuid;
		}

		return path.join(xdgBasedir.data, 'Trash');
	}
};
github kriskbx / gitlab-time-tracker / src / include / file-config.js View on Github external
get globalDir() {
        return Fs.join(xdgBaseDir.data, '.gtt');
    }

xdg-basedir

Get XDG Base Directory paths

MIT
Latest version published 3 years ago

Package Health Score

70 / 100
Full package analysis