From 66f605d297963fc6b0b2a493366ed85ec9249dd0 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 13 Feb 2017 19:59:14 +0700 Subject: [PATCH] Simplify the XDG config fallback --- index.js | 8 +++----- package.json | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index d675cda..798323e 100644 --- a/index.js +++ b/index.js @@ -1,16 +1,14 @@ 'use strict'; const path = require('path'); -const osTmpdir = require('os').tmpdir; +const os = require('os'); const fs = require('graceful-fs'); -const osenv = require('osenv'); const mkdirp = require('mkdirp'); -const uuid = require('uuid'); const xdgBasedir = require('xdg-basedir'); const writeFileAtomic = require('write-file-atomic'); const dotProp = require('dot-prop'); +const uniqueString = require('unique-string'); -const user = (osenv.user() || uuid.v4()).replace(/\\/g, ''); -const configDir = xdgBasedir.config || path.join(osTmpdir(), user, '.config'); +const configDir = xdgBasedir.config || path.join(os.tmpdir(), uniqueString()); const permissionError = 'You don\'t have access to this file.'; const defaultPathMode = 0o0700; const writeFileOptions = {mode: 0o0600}; diff --git a/package.json b/package.json index a0990d6..03df078 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,7 @@ "dot-prop": "^4.1.0", "graceful-fs": "^4.1.2", "mkdirp": "^0.5.0", - "osenv": "^0.1.0", - "uuid": "^3.0.1", + "unique-string": "^1.0.0", "write-file-atomic": "^1.1.2", "xdg-basedir": "^3.0.0" },