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

cli-helpers

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-helpers - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

dist/json.d.ts

5

dist/file.d.ts

@@ -22,3 +22,6 @@ /**

*/
export declare function writeJSONFile(file: string, data: any): void;
export declare function writeJSONFile(file: string, data: any, options?: {
top_comment?: string;
bottom_comment?: string;
}): void;
export declare class JSONFileError extends Error {

@@ -25,0 +28,0 @@ file: string;

12

dist/file.js

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

const path_1 = require("path");
const json_1 = require("./json");
/**

@@ -37,2 +38,3 @@ * @description look for the file from the given directory or parent directory recursively

let text = (0, fs_1.readFileSync)(file).toString();
text = (0, json_1.removeComments)(text);
try {

@@ -49,3 +51,3 @@ return JSON.parse(text);

*/
function writeJSONFile(file, data) {
function writeJSONFile(file, data, options) {
let text;

@@ -58,3 +60,9 @@ try {

}
(0, fs_1.writeFileSync)(file, text);
if (options?.top_comment) {
text = options.top_comment + '\n' + text;
}
if (options?.bottom_comment) {
text = text + '\n' + options.bottom_comment;
}
(0, fs_1.writeFileSync)(file, text.trim() + '\n');
}

@@ -61,0 +69,0 @@ class JSONFileError extends Error {

export * from './io';
export * from './file';
export * from './json';

@@ -19,1 +19,2 @@ "use strict";

__exportStar(require("./file"), exports);
__exportStar(require("./json"), exports);
{
"name": "cli-helpers",
"version": "1.1.1",
"version": "1.2.0",
"description": "Helper library for building cli applications",

@@ -27,10 +27,16 @@ "keywords": [

"scripts": {
"test": "tsc --noEmit",
"mocha": "ts-mocha src/*.spec.ts",
"test": "npm run mocha && tsc --noEmit",
"clean": "rimraf dist",
"build": "rimraf dist && tsc -p . && rimraf dist/tsconfig.tsbuildinfo",
"build": "rimraf dist && tsc -p . && rimraf dist/tsconfig.tsbuildinfo rimraf dist/*.spec.*",
"tsc": "tsc -p ."
},
"devDependencies": {
"@types/chai": "4",
"@types/mocha": "^10.0.8",
"@types/node": "^20.12.5",
"chai": "4",
"mocha": "^10.7.3",
"rimraf": "^5.0.5",
"ts-mocha": "^10.0.0",
"ts-node": "^10.9.2",

@@ -37,0 +43,0 @@ "ts-node-dev": "^2.0.0",

@@ -46,3 +46,4 @@ # cli-helpers

**io helper functions**:
<details>
<summary>io helper functions</summary>

@@ -66,3 +67,5 @@ ```typescript

**file helper functions**:
</details>
<details>
<summary>file helper functions</summary>

@@ -90,3 +93,10 @@ ````typescript

*/
export function writeJSONFile(file: string, data: any): void
export function writeJSONFile(
file: string,
data: any,
options?: {
top_comment?: string
bottom_comment?: string
},
): void

@@ -98,2 +108,16 @@ export class JSONFileError extends Error {

</details>
<details>
<summary>json helper functions</summary>
```typescript
/**
* @description remove comments from json text
*/
export function removeComments(text: string): string
```
</details>
## License

@@ -100,0 +124,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