Skip to content
Permalink
Browse files
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
robertrossmann committed Mar 5, 2019
1 parent 7346f8c commit 4144c3caed233a74f4b03f0c0bffe8aaf910e72c
Showing 6 changed files with 82 additions and 38 deletions.

Some generated files are not rendered by default. Learn more.

@@ -9,11 +9,14 @@
"bugs": "https://github.com/Dreamscapes/atom-ide-mocha-core/issues",
"contributors": [],
"dependencies": {
"@atom-ide/utils": "^1.0.0",
"atom-package-deps": "^5.0.0",
"hash-to-port": "^1.0.0",
"remote-event-emitter": "^1.1.0",
"stack-utils": "^1.0.1"
},
"bundledDependencies": [
"@atom-ide/utils"
],
"engines": {
"atom": "^1.32.0",
"node": "^10.0.0"
@@ -1,22 +1,7 @@
import * as os from 'os'
import * as path from 'path'
import * as hashToPort from 'hash-to-port'
import { mkaddress } from '@atom-ide/utils'

const CONSOLE_VIEW_URI = 'atom://nuclide/console'

function mkaddress({ root, type = 'unix' }) {
const name = path.basename(root)

switch (type) {
case 'unix':
return path.resolve(os.tmpdir(), `ide-mocha-${name}.sock`)
case 'IP':
return hashToPort(name)
default:
throw new Error(`Unknown address interface type: ${type}`)
}
}

function mkcommandinfo({ address }) {
return [
'npx mocha',

Some generated files are not rendered by default. Learn more.

@@ -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"
}
}
@@ -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,
}

0 comments on commit 4144c3c

Please sign in to comment.