This repository has been archived by the owner on Jul 17, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): move socket/port creation to a bundled dependency 🎨
This prepares us for making the socket/port location generation code to be shared between the UI and the reporter, thus allowing end users to omit the socket address from the config in most circumstances. 😍
- Loading branch information
1 parent
7346f8c
commit 4144c3c
Showing
6 changed files
with
82 additions
and
38 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "@atom-ide/utils", | ||
"description": "Code shared across multiple core packages in this monorepo", | ||
"version": "1.0.0", | ||
"author": "Robert Rossmann <rr.rossmann@me.com>", | ||
"bugs": "https://github.com/Dreamscapes/atom-ide-mocha-core/issues", | ||
"contributors": [], | ||
"dependencies": { | ||
"hash-to-port": "^1.0.0" | ||
}, | ||
"homepage": "https://github.com/Dreamscapes/atom-ide-mocha-core/tree/master/packages/utils", | ||
"keywords": [], | ||
"license": "BSD-3-Clause", | ||
"main": "src", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/Dreamscapes/atom-ide-mocha-core.git" | ||
} | ||
} |
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,29 @@ | ||
import * as os from 'os' | ||
import * as path from 'path' | ||
import * as hashToPort from 'hash-to-port' | ||
|
||
/** | ||
* Create a socket address or port in a deterministic way for a given absolute directory path | ||
* | ||
* @param {Object} options Function options | ||
* @param {String} options.root Absolute path to the directory | ||
* @param {String} options.mode Interface mode. Either `unix` or `ip`. | ||
* @return {String} A full path to the socket | ||
*/ | ||
function mkaddress({ root, mode = 'unix' }) { | ||
const name = path.basename(root) | ||
|
||
switch (mode) { | ||
case 'unix': | ||
return path.resolve(os.tmpdir(), `ide-mocha-${name}.sock`) | ||
case 'IP': | ||
case 'ip': | ||
return hashToPort(name) | ||
default: | ||
throw new Error(`Unknown address interface mode: ${mode}`) | ||
} | ||
} | ||
|
||
export { | ||
mkaddress, | ||
} |