UNPKG

1.06 kBJavaScriptView Raw
1'use strict';
2
3// Node.js built-ins
4
5const os = require('os');
6const path = require('path');
7
8// foreign modules
9
10const AppDirectory = require('appdirectory');
11
12// local modules
13
14const pkg = require('../package.json');
15
16// this module
17
18const CONFIG_FILE = '.blinkmrc.json';
19
20// use ~/.config in OS X (like Linux), dotfiles are better for CLIs
21const platform = (() => {
22 const p = os.platform();
23 if (p === 'darwin') {
24 return 'linux';
25 }
26 return p;
27})();
28
29const dirs = new AppDirectory({
30 appName: pkg.name,
31 platform,
32 useRoaming: false
33});
34
35const USER_CONFIG_DIR = dirs.userConfig();
36
37const MAX_REQUESTS = 5;
38
39module.exports = {
40 CONFIG_FILE,
41 MAX_REQUESTS
42};
43
44Object.defineProperty(module.exports, 'USER_CONFIG_DIR', {
45 enumerable: true,
46 get () {
47 return process.env.BMP_USER_CONFIG_DIR || USER_CONFIG_DIR;
48 }
49});
50
51Object.defineProperty(module.exports, 'USER_CONFIG_FILE', {
52 enumerable: true,
53 get () {
54 const dirPath = process.env.BMP_USER_CONFIG_DIR || USER_CONFIG_DIR;
55 return path.join(dirPath, 'blinkmrc.json');
56 }
57});