Skip to content

Commit 982fe69

Browse files
committed
Merge pull request #41 from Mopolo/windows-support
Windows support
2 parents 77ddb35 + 2d42e50 commit 982fe69

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

lib/config.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
var _ = require('lodash');
2-
var fs = require('fs');
3-
var path = require('path');
4-
var extend = require('deep-extend');
1+
var _ = require('lodash');
2+
var fs = require('fs');
3+
var path = require('path');
4+
var extend = require('deep-extend');
5+
var osHomedir = require('os-homedir');
56

67
var config = null;
78

@@ -16,9 +17,9 @@ exports.get = function() {
1617

1718
function load() {
1819
var DEFAULT = path.join(__dirname, '..', 'config.json');
19-
var CUSTOM = path.join(process.env['HOME'], '.tldrrc');
20+
var CUSTOM = path.join(osHomedir(), '.tldrrc');
2021
var defaultConfig = JSON.parse(fs.readFileSync(DEFAULT));
21-
defaultConfig.cache = path.join(process.env['HOME'], '.tldr');
22+
defaultConfig.cache = path.join(osHomedir(), '.tldr');
2223
defaultConfig.proxy = process.env.HTTP_PROXY || process.env.http_proxy;
2324

2425
var customConfig = {};

lib/platform.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ var folders = {
55
'osx': 'osx',
66
'darwin': 'osx',
77
'linux': 'linux',
8-
'sunos': 'sunos'
8+
'sunos': 'sunos',
9+
'win32': 'win32'
910
};
1011

1112
function isSupported(platform) {

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
"lint": "eslint lib test bin/tldr",
3939
"watch": "npm run test:quiet -- --reporter=min --watch --growl"
4040
},
41-
"os": [
42-
"!win32"
43-
],
4441
"dependencies": {
4542
"async": "~1.5.0",
4643
"colors": "~1.1.2",
@@ -51,6 +48,7 @@
5148
"marked": "~0.3.5",
5249
"mkdirp": "~0.5.1",
5350
"ms": "~0.7.1",
51+
"os-homedir": "^1.0.1",
5452
"request": "~2.67.0",
5553
"rimraf": "~2.5.0",
5654
"string": "~3.3.1",

test/platform.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ describe('Platform', function() {
4040
});
4141

4242
describe('isSupported', function() {
43-
it('should tell that Linux, OSX and SunOS are supported', function() {
43+
it('should tell that Linux, OSX, SunOS and Win32 are supported', function() {
4444
platform.isSupported('osx').should.eql(true);
4545
platform.isSupported('linux').should.eql(true);
4646
platform.isSupported('sunos').should.eql(true);
47-
platform.isSupported('windows').should.eql(false); // Yet
47+
platform.isSupported('win32').should.eql(true);
4848
platform.isSupported('ios').should.eql(false);
4949
});
5050
});

0 commit comments

Comments
 (0)