Skip to content
This repository was archived by the owner on Jun 5, 2019. It is now read-only.

Commit a011c76

Browse files
authored
Merge pull request #51 from skellock/fix-platform
Adds tests and fixes platform detection.
2 parents 913e4ae + 1305a15 commit a011c76

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { test } from 'ava'
2+
import { stub } from 'sinon'
3+
import { isLinux, isMac, isWindows } from './platform'
4+
5+
const platformStub = stub(process, 'platform')
6+
7+
test.afterEach.always(() => {
8+
platformStub.restore()
9+
})
10+
11+
test('detects linux', t => {
12+
platformStub.get(() => 'linux')
13+
t.true(isLinux())
14+
})
15+
16+
test('detects windows', t => {
17+
platformStub.get(() => 'win32')
18+
t.true(isWindows())
19+
})
20+
21+
test('detects mac', t => {
22+
platformStub.get(() => 'darwin')
23+
t.true(isMac())
24+
})

src/shared/utils/platform/platform.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export function isLinux() {
2-
return process.platform.includes('linux')
2+
return process.platform === 'linux'
33
}
44

55
export function isWindows() {
6-
return process.platform.includes('win')
6+
return process.platform === 'win32'
77
}
88

99
export function isMac() {

0 commit comments

Comments
 (0)