Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pm2wick

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pm2wick - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

13

lib/generateId.ts

@@ -6,20 +6,10 @@ import * as fs from 'fs';

const ID_FILE = path.join(__dirname, '..', 'user-id.txt');
console.log('Saving user ID to:', ID_FILE);
/**
* Generates a unique ID and saves it to a file, or retrieves the existing ID if already generated.
*
* @param {typeof fs} customFs - An optional custom file system module for testing or alternate environments.
* @returns {string} - The unique ID.
* @throws Will throw an error if reading or writing the ID file fails.
*/
export function generateUniqueId(customFs = fs): string {
try {
// Check if the ID file already exists
if (customFs.existsSync(ID_FILE)) {
// Read and return the existing unique ID
return customFs.readFileSync(ID_FILE, 'utf-8').trim();
} else {
// Generate a new unique ID using uuidv4
const uniqueId = uuidv4();
// Save the generated ID to the file
customFs.writeFileSync(ID_FILE, uniqueId, 'utf-8');

@@ -30,5 +20,4 @@ return uniqueId;

console.error('Failed to generate or read unique ID:', error);
// Re-throw the error to allow further handling by the caller
throw error;
}
}

2

package.json
{
"name": "pm2wick",
"version": "1.0.0",
"version": "1.1.0",
"description": "Manage your PM2 processes.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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