-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd44d11
commit fc46ab4
Showing
5 changed files
with
128 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch", | ||
"type": "node", | ||
"request": "launch", | ||
"program": "${workspaceRoot}/src/index.js", | ||
"stopOnEntry": false, | ||
"args": [], | ||
"cwd": "${workspaceRoot}", | ||
"preLaunchTask": null, | ||
"runtimeExecutable": null, | ||
"runtimeArgs": [ | ||
"--nolazy" | ||
], | ||
"env": { | ||
"NODE_ENV": "development" | ||
}, | ||
"console": "internalConsole", | ||
"sourceMaps": false, | ||
"outDir": null | ||
}, | ||
{ | ||
"name": "Attach", | ||
"type": "node", | ||
"request": "attach", | ||
"port": 5858, | ||
"address": "localhost", | ||
"restart": false, | ||
"sourceMaps": false, | ||
"outDir": null, | ||
"localRoot": "${workspaceRoot}", | ||
"remoteRoot": null | ||
}, | ||
{ | ||
"name": "Attach to Process", | ||
"type": "node", | ||
"request": "attach", | ||
"processId": "${command.PickProcess}", | ||
"port": 5858, | ||
"sourceMaps": false, | ||
"outDir": null | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const os = require('os') | ||
|
||
const utils = { | ||
/** | ||
* Gets the version of Windows | ||
* @param {string} [version=os.release()] Release value to test | ||
* | ||
* @returns {number} Major & minor of Windows (8.0, 8.1, 10) | ||
*/ | ||
|
||
getWindowsVersion (version = os.release()) { | ||
let match = version.match(/^(\d+).?(\d+).?(\*|\d+)$/) | ||
|
||
// We got major, minor | ||
if (match.length > 2 && match[1] === '6' && match[2] === '1') { | ||
return '7.0' | ||
} else if (match.length > 2 && match[1] === '6' && match[2] === '2') { | ||
return '8.0' | ||
} else if (match.length > 2 && match[1] === '6' && match[2] === '3') { | ||
return '8.1' | ||
} else if (match.length > 2 && match[1] === '10' && match[2] === '0') { | ||
return '10.0' | ||
} else if (match.length > 2) { | ||
return `${match[1]}.${match[2]}` | ||
} else { | ||
return version | ||
} | ||
}, | ||
|
||
/** | ||
* @returns {boolean} Is Windows | ||
*/ | ||
getIsWindows (platform = os.platform()) { | ||
return platform === 'win32' | ||
} | ||
} | ||
|
||
module.exports = utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const { getWindowsVersion, getIsWindows } = require('../../src/utils') | ||
|
||
|
||
describe('Utils', () => { | ||
it('getWindowsVersion returns 10.0 for Windows 10', () => { | ||
let version = getWindowsVersion('10.0.14393') | ||
version.should.be.equal('10.0') | ||
}) | ||
|
||
it('getWindowsVersion returns 8.1 for Windows 8.1', () => { | ||
let version = getWindowsVersion('6.3.9600') | ||
version.should.be.equal('8.1') | ||
}) | ||
|
||
it('getWindowsVersion returns 8 for Windows 8', () => { | ||
let version = getWindowsVersion('6.2.9600') | ||
version.should.be.equal('8.0') | ||
}) | ||
|
||
it('getWindowsVersion returns 7 for Windows 7', () => { | ||
let version = getWindowsVersion('6.1.9600') | ||
version.should.be.equal('7.0') | ||
}) | ||
|
||
it('getIsWindows returns true for Windows', () => { | ||
let platform = getIsWindows('win32') | ||
platform.should.be.equal(true) | ||
}) | ||
|
||
it('getIsWindows returns false for macOS', () => { | ||
let platform = getIsWindows('darwin') | ||
platform.should.be.equal(false) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const chai = require('chai') | ||
|
||
chai.should() | ||
|
||
// Run tests | ||
require('./src/utils') |