@graphql-markdown/utils
Advanced tools
Comparing version 1.6.5 to 1.7.0
@@ -6,4 +6,3 @@ /** | ||
*/ | ||
/// <reference types="node" /> | ||
import type { PrettifyCallbackFunction } from "@graphql-markdown/types"; | ||
import type { EnsureDirOptions, PrettifyCallbackFunction } from "@graphql-markdown/types"; | ||
export { readFile, copyFile } from "node:fs/promises"; | ||
@@ -45,3 +44,3 @@ /** | ||
*/ | ||
export declare const ensureDir: (location: string) => Promise<void>; | ||
export declare const ensureDir: (location: string, options?: EnsureDirOptions) => Promise<void>; | ||
/** | ||
@@ -48,0 +47,0 @@ * Asynchronously save a file with a string content at specified location in local FS. |
@@ -37,3 +37,3 @@ "use strict"; | ||
} | ||
catch (error) { | ||
catch { | ||
return false; | ||
@@ -59,6 +59,11 @@ } | ||
*/ | ||
const ensureDir = async (location) => { | ||
const ensureDir = async (location, options) => { | ||
if (!(await (0, exports.fileExists)(location))) { | ||
await (0, promises_1.mkdir)(location, { recursive: true }); | ||
return; | ||
} | ||
if (options && options.forceEmpty === true) { | ||
await (0, promises_1.rm)(location, { recursive: true }); | ||
await (0, exports.ensureDir)(location); | ||
} | ||
}; | ||
@@ -65,0 +70,0 @@ exports.ensureDir = ensureDir; |
@@ -33,2 +33,2 @@ /** | ||
*/ | ||
export declare const isEmpty: (obj: unknown) => boolean; | ||
export declare const isEmpty: <T extends Record<string, unknown>>(obj: unknown) => obj is Exclude<typeof obj, T>; |
@@ -39,17 +39,1 @@ /** | ||
export declare const prettifyMarkdown: (content: string) => Promise<string | undefined>; | ||
/** | ||
* Prettify a Javascript string using {@link prettify} and `babel` parser. | ||
* | ||
* @remarks | ||
* Same as `prettify(content, "babel")`. | ||
* | ||
* @see {@link prettify} | ||
* | ||
* @internal | ||
* | ||
* @param content - the string to be prettified. | ||
* | ||
* @returns a prettified string, or undefined if an error occurred. | ||
* | ||
*/ | ||
export declare const prettifyJavascript: (content: string) => Promise<string | undefined>; |
@@ -31,3 +31,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.prettifyJavascript = exports.prettifyMarkdown = exports.prettify = void 0; | ||
exports.prettifyMarkdown = exports.prettify = void 0; | ||
/* istanbul ignore file */ | ||
@@ -56,4 +56,4 @@ // Stryker disable all | ||
} | ||
catch (error) { | ||
if ("logger" in global) { | ||
catch { | ||
if ("logger" in global && global.logger) { | ||
global.logger._log("Prettier is not found"); | ||
@@ -87,20 +87,1 @@ } | ||
exports.prettifyMarkdown = prettifyMarkdown; | ||
/** | ||
* Prettify a Javascript string using {@link prettify} and `babel` parser. | ||
* | ||
* @remarks | ||
* Same as `prettify(content, "babel")`. | ||
* | ||
* @see {@link prettify} | ||
* | ||
* @internal | ||
* | ||
* @param content - the string to be prettified. | ||
* | ||
* @returns a prettified string, or undefined if an error occurred. | ||
* | ||
*/ | ||
const prettifyJavascript = async (content) => { | ||
return (0, exports.prettify)(content, "babel"); | ||
}; | ||
exports.prettifyJavascript = prettifyJavascript; |
@@ -6,3 +6,2 @@ /** | ||
*/ | ||
/// <reference types="node" /> | ||
export { join, resolve } from "node:path/posix"; |
@@ -8,3 +8,3 @@ { | ||
}, | ||
"version": "1.6.5", | ||
"version": "1.7.0", | ||
"license": "MIT", | ||
@@ -11,0 +11,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34845
1026