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

dprint

Package Overview
Dependencies
Maintainers
1
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dprint - npm Package Compare versions

Comparing version 0.9.1 to 0.10.0

65

dist/dprint.js

@@ -9,3 +9,2 @@ 'use strict';

var core = require('@dprint/core');
var crypto = require('crypto');
var fs = require('fs');

@@ -88,3 +87,3 @@ var path = require('path');

function getPackageVersion() {
return "0.9.1";
return "0.10.0";
}

@@ -135,3 +134,3 @@

class CrashSafeFileWriter {
class KillSafeFileWriter {
constructor(environment) {

@@ -144,3 +143,4 @@ this.environment = environment;

for (const filePath of this.tempFiles.values())
this.tryDeleteFile(filePath);
this.tryDeleteFileSync(filePath);
this.tempFiles.clear();
};

@@ -152,24 +152,33 @@ process.on("SIGINT", this.crashCleanup);

dispose() {
process.off("SIGINT", this.crashCleanup);
process.off("SIGUSR1", this.crashCleanup);
process.off("SIGUSR2", this.crashCleanup);
return __awaiter(this, void 0, void 0, function* () {
process.off("SIGINT", this.crashCleanup);
process.off("SIGUSR1", this.crashCleanup);
process.off("SIGUSR2", this.crashCleanup);
const tempFiles = Array.from(this.tempFiles.values());
return Promise.all(tempFiles.map(filePath => this.tryDeleteFile(filePath)));
});
}
writeFile(filePath, fileText) {
return __awaiter(this, void 0, void 0, function* () {
let tempFilePath = this.getTempFileName(filePath);
const tempFilePath = this.getTempFileName(filePath);
this.tempFiles.add(tempFilePath);
yield this.environment.writeFile(tempFilePath, fileText);
if (this.crashed) {
this.tryDeleteFile(tempFilePath);
this.tryDeleteFileSync(tempFilePath);
return;
}
yield this.environment.rename(tempFilePath, filePath);
this.tempFiles.delete(tempFilePath);
});
}
tryDeleteFile(filePath) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield this.environment.rename(tempFilePath, filePath);
yield this.environment.unlink(filePath);
}
finally {
this.tempFiles.delete(tempFilePath);
catch (_a) {
}
});
}
tryDeleteFile(filePath) {
tryDeleteFileSync(filePath) {
try {

@@ -182,3 +191,3 @@ this.environment.unlinkSync(filePath);

getTempFileName(filePath) {
return filePath + crypto.randomBytes(4).readUInt32LE(0) + ".temp";
return filePath + ".dprint_temp";
}

@@ -236,2 +245,15 @@ }

}
function unlink(filePath) {
return new Promise((resolve, reject) => {
fs.unlink(filePath, err => {
if (err)
reject(err);
else
resolve();
});
});
}
function unlinkSync(filePath) {
fs.unlinkSync(filePath);
}

@@ -336,3 +358,3 @@ function resolveConfigFile(filePath, environment) {

const promises = [];
const crashSafeFileWriter = new CrashSafeFileWriter(environment);
const killSafeFileWriter = new KillSafeFileWriter(environment);
try {

@@ -346,3 +368,3 @@ for (const filePath of filePaths) {

});
return result === fileText ? Promise.resolve() : crashSafeFileWriter.writeFile(filePath, result);
return result === fileText ? Promise.resolve() : killSafeFileWriter.writeFile(filePath, result);
}).catch(err => {

@@ -357,3 +379,3 @@ const errorText = err.toString().replace("[dprint]: ", "");

finally {
crashSafeFileWriter.dispose();
yield killSafeFileWriter.dispose();
}

@@ -404,5 +426,3 @@ function updatePluginsWithConfiguration() {

const allFilePaths = yield environment.glob(getFileGlobs());
return options.allowNodeModuleFiles
? allFilePaths
: allFilePaths.filter(filePath => !isInNodeModules.test(filePath));
return options.allowNodeModuleFiles ? allFilePaths : allFilePaths.filter(filePath => !isInNodeModules.test(filePath));
function getFileGlobs() {

@@ -527,4 +547,7 @@ return [...getIncludes(), ...getExcludes()];

}
unlink(filePath) {
return unlink(filePath);
}
unlinkSync(filePath) {
fs.unlinkSync(filePath);
unlinkSync(filePath);
}

@@ -531,0 +554,0 @@ }

@@ -30,2 +30,3 @@ import { CliLoggingEnvironment } from "@dprint/core";

rename(oldFilePath: string, newFilePath: string): Promise<void>;
unlink(filePath: string): Promise<void>;
unlinkSync(filePath: string): void;

@@ -44,3 +45,4 @@ }

rename(oldFilePath: string, newFilePath: string): Promise<void>;
unlink(filePath: string): void;
unlinkSync(filePath: string): void;
}
{
"name": "dprint",
"version": "0.9.1",
"version": "0.10.0",
"description": "TypeScript and JSONC code formatter.",

@@ -38,4 +38,4 @@ "main": "dist/dprint.js",

"dependencies": {
"@dprint/core": "~0.6.0",
"@dprint/types": "~0.2.0",
"@dprint/core": "~0.7.0",
"@dprint/types": "~0.3.0",
"fast-glob": "^3.2.2",

@@ -49,3 +49,2 @@ "minimist": "^1.2.5"

"@types/node": "^13.9.5",
"@types/tmp": "^0.1.0",
"@types/ts-nameof": "^4.2.1",

@@ -52,0 +51,0 @@ "chai": "^4.2.0",

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