Skip to content

Commit

Permalink
fix: make the config dir first
Browse files Browse the repository at this point in the history
  • Loading branch information
davewasmer committed Mar 30, 2017
1 parent 5b74207 commit fab033a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -31,12 +31,14 @@
"@types/configstore": "^2.1.1",
"@types/get-port": "^0.0.4",
"@types/glob": "^5.0.30",
"@types/mkdirp": "^0.3.29",
"@types/node": "^7.0.11",
"@types/tmp": "^0.0.32",
"command-exists": "^1.2.2",
"configstore": "^3.0.0",
"get-port": "^3.0.0",
"glob": "^7.1.1",
"mkdirp": "^0.5.1",
"tmp": "^0.0.31",
"tslib": "^1.6.0"
}
Expand Down
8 changes: 5 additions & 3 deletions src/index.ts
Expand Up @@ -13,21 +13,23 @@ import { execSync } from 'child_process';
import * as tmp from 'tmp';
import * as glob from 'glob';
import * as Configstore from 'configstore';
import * as mkdirp from 'mkdirp';
import { sync as commandExists } from 'command-exists';

const isMac = process.platform === 'darwin';
const isLinux = process.platform === 'linux';
const isWindows = process.platform === 'win32';

// use %LOCALAPPDATA%/Yarn on Windows otherwise use ~/.config/yarn
// use %LOCALAPPDATA%/devcert on Windows otherwise use ~/.config/devcert
let configDir: string;
if (isWindows && process.env.LOCALAPPDATA) {
configDir = path.join(process.env.LOCALAPPDATA, 'Yarn', 'config');
configDir = path.join(process.env.LOCALAPPDATA, 'devcert', 'config');
} else {
let uid = process.getuid && process.getuid();
let userHome = (isLinux && uid === 0) ? path.resolve('/usr/local/share') : require('os').homedir();
configDir = path.join(userHome, '.config', 'yarn');
configDir = path.join(userHome, '.config', 'devcert');
}
mkdirp.sync(configDir);
const configPath: (...pathSegments: string[]) => string = path.join.bind(path, configDir);

const opensslConfPath = path.join(__dirname, '..', 'openssl.conf');
Expand Down
6 changes: 5 additions & 1 deletion yarn.lock
Expand Up @@ -21,6 +21,10 @@
version "2.0.29"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-2.0.29.tgz#5002e14f75e2d71e564281df0431c8c1b4a2a36a"

"@types/mkdirp@^0.3.29":
version "0.3.29"
resolved "https://registry.yarnpkg.com/@types/mkdirp/-/mkdirp-0.3.29.tgz#7f2ad7ec55f914482fc9b1ec4bb1ae6028d46066"

"@types/node@*", "@types/node@^7.0.11":
version "7.0.11"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.11.tgz#55680189f2335f080f0aeb57871f0b9823646d89"
Expand Down Expand Up @@ -664,7 +668,7 @@ minimist@^1.1.3:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"

mkdirp@^0.5.0:
mkdirp@^0.5.0, mkdirp@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
dependencies:
Expand Down

0 comments on commit fab033a

Please sign in to comment.