New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ensure-port

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ensure-port - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

18

dist/cjs/ensure-port.js

@@ -1,9 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Ports = void 0;
const node_1 = require("@file-services/node");
const create_listening_server_1 = require("create-listening-server");
const find_cache_dir_js_1 = require("./find-cache-dir.js");
class Ports {
constructor({ startPort = 8000, endPort = 9000, strategy = 'random' } = {}, { fs = node_1.nodeFs, rootDir = process.cwd() } = {}) {
import { nodeFs } from '@file-services/node';
import { safeListeningHttpServer } from 'create-listening-server';
import { findCacheDir } from './find-cache-dir.js';
export class Ports {
constructor({ startPort = 8000, endPort = 9000, strategy = 'random' } = {}, { fs = nodeFs, rootDir = process.cwd() } = {}) {
this.totalPorts = new Set();

@@ -17,3 +14,3 @@ this.localPorts = new Set();

this.initialEdges = { start: this.start, end: this.end, reached: false };
const tempDir = (0, find_cache_dir_js_1.findCacheDir)('ensure-port', { fs: this.fs, rootDir: this.rootDir });
const tempDir = findCacheDir('ensure-port', { fs: this.fs, rootDir: this.rootDir });
if (tempDir) {

@@ -43,3 +40,3 @@ this.fs.ensureDirectorySync(tempDir);

const preferredPort = await this.getPort();
const { port, httpServer } = await (0, create_listening_server_1.safeListeningHttpServer)(preferredPort);
const { port, httpServer } = await safeListeningHttpServer(preferredPort);
if (port !== preferredPort) {

@@ -152,3 +149,2 @@ await this.set(port);

}
exports.Ports = Ports;
function randomNumberBetween(min, max) {

@@ -155,0 +151,0 @@ return Math.floor(Math.random() * (max - min + 1) + min);

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findCacheDir = void 0;
const package_dir_js_1 = require("./package-dir.js");
function findCacheDir(name, { fs, rootDir }) {
import { packageDirectory } from './package-dir.js';
export function findCacheDir(name, { fs, rootDir }) {
if (process.env.CACHE_DIR && !['true', 'false', '1', '0'].includes(process.env.CACHE_DIR)) {

@@ -11,3 +8,3 @@ const dir = fs.join(process.env.CACHE_DIR, name);

}
rootDir = (0, package_dir_js_1.packageDirectory)({ fs, cwd: rootDir !== null && rootDir !== void 0 ? rootDir : process.cwd() });
rootDir = packageDirectory({ fs, cwd: rootDir !== null && rootDir !== void 0 ? rootDir : process.cwd() });
if (!rootDir) {

@@ -22,3 +19,2 @@ return;

}
exports.findCacheDir = findCacheDir;
function getNodeModuleDirectory(directory, fs) {

@@ -25,0 +21,0 @@ const nodeModules = fs.join(directory, 'node_modules');

@@ -1,6 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Ports = void 0;
var ensure_port_js_1 = require("./ensure-port.js");
Object.defineProperty(exports, "Ports", { enumerable: true, get: function () { return ensure_port_js_1.Ports; } });
export { Ports } from './ensure-port.js';
//# sourceMappingURL=index.js.map

@@ -1,9 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.packageDirectory = void 0;
function packageDirectory({ fs, cwd }) {
export function packageDirectory({ fs, cwd }) {
const file = fs.findClosestFileSync(cwd, 'package.json');
return file && fs.dirname(file);
}
exports.packageDirectory = packageDirectory;
//# sourceMappingURL=package-dir.js.map
{
"name": "ensure-port",
"version": "1.2.0",
"version": "1.2.1",
"description": "Makes sure you get an available port",
"type": "module",
"main": "dist/cjs/index.js",

@@ -53,2 +54,3 @@ "typings": "dist/mjs/index.d.ts",

"ts-expect": "^1.3.0",
"ts-node": "^10.8.1",
"typescript": "^4.7.4"

@@ -55,0 +57,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc