Socket
Socket
Sign inDemoInstall

@salesforce/core

Package Overview
Dependencies
Maintainers
47
Versions
499
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salesforce/core - npm Package Compare versions

Comparing version 8.2.8 to 8.2.9

2

lib/config/configFile.js

@@ -178,2 +178,3 @@ "use strict";

this.logger.debug(`Reading config file: ${this.getPath()} because ${!this.hasRead ? 'hasRead is false' : 'force parameter is true'}`);
await (0, fileLocking_1.pollUntilUnlock)(this.getPath());
const obj = (0, kit_1.parseJsonMap)(await fs.promises.readFile(this.getPath(), 'utf8'), this.getPath());

@@ -214,2 +215,3 @@ this.setContentsFromFileContents(obj, (await fs.promises.stat(this.getPath(), { bigint: true })).mtimeNs);

if (!this.hasRead || force) {
(0, fileLocking_1.pollUntilUnlockSync)(this.getPath());
this.logger.debug(`Reading config file: ${this.getPath()}`);

@@ -216,0 +218,0 @@ const obj = (0, kit_1.parseJsonMap)(fs.readFileSync(this.getPath(), 'utf8'));

@@ -24,2 +24,9 @@ type LockInitResponse = {

export declare const lockInitSync: (filePath: string) => LockInitSyncResponse;
/**
* Poll until the file is unlocked.
*
* @param filePath file path to check
*/
export declare const pollUntilUnlock: (filePath: string) => Promise<void>;
export declare const pollUntilUnlockSync: (filePath: string) => void;
export {};

@@ -26,3 +26,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.lockInitSync = exports.lockInit = void 0;
exports.pollUntilUnlockSync = exports.pollUntilUnlock = exports.lockInitSync = exports.lockInit = void 0;
/*

@@ -37,2 +37,4 @@ * Copyright (c) 2023, salesforce.com, inc.

const proper_lockfile_1 = require("proper-lockfile");
const kit_1 = require("@salesforce/kit");
const ts_retry_promise_1 = require("ts-retry-promise");
const sfError_1 = require("../sfError");

@@ -116,2 +118,38 @@ const logger_1 = require("../logger/logger");

exports.lockInitSync = lockInitSync;
/**
* Poll until the file is unlocked.
*
* @param filePath file path to check
*/
const pollUntilUnlock = async (filePath) => {
try {
await (0, ts_retry_promise_1.retryDecorator)(proper_lockfile_1.check, {
timeout: kit_1.Duration.minutes(1).milliseconds,
delay: 10,
until: (locked) => locked === false,
// don't retry errors (typically enoent or access on the lockfile, therefore not locked)
retryIf: () => false,
})(filePath, lockRetryOptions_1.lockRetryOptions);
}
catch (e) {
// intentionally swallow the error, same reason as above
}
};
exports.pollUntilUnlock = pollUntilUnlock;
const pollUntilUnlockSync = (filePath) => {
// Set a counter to ensure that the while loop does not run indefinitely
let counter = 0;
let locked = true;
while (locked && counter < 100) {
try {
locked = (0, proper_lockfile_1.checkSync)(filePath, lockRetryOptions_1.lockOptions);
counter++;
}
catch {
// Likely a file not found error, which means the file is not locked
locked = false;
}
}
};
exports.pollUntilUnlockSync = pollUntilUnlockSync;
//# sourceMappingURL=fileLocking.js.map

5

package.json
{
"name": "@salesforce/core",
"version": "8.2.8",
"version": "8.2.9",
"description": "Core libraries to interact with SFDX projects, orgs, and APIs.",

@@ -38,2 +38,3 @@ "main": "lib/index",

"test": "wireit",
"test:nuts": "mocha \"test/**/*.nut.ts\" --timeout 500000",
"test:only": "wireit",

@@ -150,3 +151,3 @@ "test:perf": "ts-node test/perf/logger/main.test.ts"

"test:only": {
"command": "nyc mocha \"test/**/*Test.ts\"",
"command": "nyc mocha \"test/unit/**/*.test.ts\"",
"env": {

@@ -153,0 +154,0 @@ "FORCE_COLOR": "2"

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