forked from microsoft/VoTT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v2' into jamangia/tf-pascal-voc-exporter-v2
- Loading branch information
Showing
57 changed files
with
5,651 additions
and
3,323 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
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 @@ | ||
HOST_TYPE=electron |
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 @@ | ||
# Debugging Guide |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,41 @@ | ||
import getHostProcess, { HostProcessType } from "./hostProcess"; | ||
|
||
jest.mock("os"); | ||
import os from "os"; | ||
|
||
describe("Host Process", () => { | ||
let originalHostType: string = null; | ||
|
||
beforeAll(() => { | ||
originalHostType = process.env.HOST_TYPE; | ||
process.env.HOST_TYPE = ""; | ||
}); | ||
|
||
afterAll(() => { | ||
process.env.HOST_TYPE = originalHostType; | ||
}); | ||
|
||
it("sets host process type to electron when running as electron", () => { | ||
// tslint:disable-next-line:max-line-length | ||
const expectedRelease = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) vott-react-typescript/0.1.0 Chrome/66.0.3359.181 Electron/3.0.13 Safari/537.36"; | ||
const releaseMock = os.release as jest.Mock; | ||
releaseMock.mockImplementationOnce(() => expectedRelease); | ||
|
||
const hostProcess = getHostProcess(); | ||
|
||
expect(hostProcess.type).toEqual(HostProcessType.Electron); | ||
expect(hostProcess.release).toEqual(expectedRelease.toLowerCase()); | ||
}); | ||
|
||
it("sets host process type to browser when not electron", () => { | ||
// tslint:disable-next-line:max-line-length | ||
const expectedRelease = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"; | ||
const releaseMock = os.release as jest.Mock; | ||
releaseMock.mockImplementationOnce(() => expectedRelease); | ||
|
||
const hostProcess = getHostProcess(); | ||
|
||
expect(hostProcess.type).toEqual(HostProcessType.Browser); | ||
expect(hostProcess.release).toEqual(expectedRelease.toLowerCase()); | ||
}); | ||
}); |
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,39 @@ | ||
import os from "os"; | ||
|
||
/** | ||
* @name - Host Process | ||
* @description - Describes the host process | ||
* @member type - The type of the host process (electron, browser, etc) | ||
* @member release - The release string of the host process | ||
*/ | ||
export interface IHostProcess { | ||
type: HostProcessType; | ||
release: string; | ||
} | ||
|
||
/** | ||
* @enum ELECTRON - Electron Host Process Type | ||
* @enum BROWSER - Browser Host Process Type | ||
*/ | ||
export enum HostProcessType { | ||
Electron = 1, // bits: 01 | ||
Browser = 2, // bits: 10 | ||
All = 3, // bits: 11 | ||
} | ||
|
||
function getHostProcess(): IHostProcess { | ||
const osRelease = os.release().toLowerCase(); | ||
let hostProcessType: HostProcessType; | ||
if (osRelease.indexOf("electron") > -1 || process.env.HOST_TYPE === "electron") { | ||
hostProcessType = HostProcessType.Electron; | ||
} else { | ||
hostProcessType = HostProcessType.Browser; | ||
} | ||
|
||
return { | ||
release: osRelease, | ||
type: hostProcessType, | ||
}; | ||
} | ||
|
||
export default getHostProcess; |
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
Oops, something went wrong.