@prettier/cli
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -16,8 +16,7 @@ import isBinaryPath from "is-binary-path"; | ||
const logger = new Logger(options.logLevel); | ||
if (options.check) { | ||
logger.log("Checking formatting..."); | ||
} | ||
const spinner = options.check ? logger.spinner.log() : undefined; | ||
spinner?.start("Checking formatting..."); | ||
const rootPath = process.cwd(); | ||
const projectPath = getProjectPath(rootPath); | ||
const [filesPaths, filesFoundPaths, foldersFoundPaths] = await getTargetsPaths(projectPath, options.globs); | ||
const [filesPaths, filesFoundPaths, foldersFoundPaths] = await getTargetsPaths(rootPath, options.globs); | ||
const filesPathsTargets = filesPaths.filter(negate(isBinaryPath)).sort(); | ||
@@ -53,12 +52,18 @@ const [foldersPathsTargetsUnsorted, foldersExtraPaths] = getExpandedFoldersPaths(foldersFoundPaths, projectPath); | ||
}; | ||
if (options.check || options.list) { | ||
return prettier.checkWithPath(filePath, getFormatOptions); | ||
try { | ||
if (options.check || options.list) { | ||
return await prettier.checkWithPath(filePath, getFormatOptions); | ||
} | ||
else if (options.write) { | ||
return await prettier.writeWithPath(filePath, getFormatOptions); | ||
} | ||
else { | ||
return await prettier.formatWithPath(filePath, getFormatOptions); | ||
} | ||
} | ||
else if (options.write) { | ||
return prettier.writeWithPath(filePath, getFormatOptions); | ||
finally { | ||
spinner?.update(fastRelativePath(rootPath, filePath)); | ||
} | ||
else { | ||
return prettier.formatWithPath(filePath, getFormatOptions); | ||
} | ||
})); | ||
spinner?.stop("Checking formatting..."); | ||
let totalFound = filesResults.length; | ||
@@ -65,0 +70,0 @@ let totalFormatted = 0; |
@@ -0,1 +1,2 @@ | ||
import Spinner from "tiny-spinner"; | ||
import type { FunctionMaybe, LogLevel } from "./types.js"; | ||
@@ -24,3 +25,12 @@ declare class Logger { | ||
}; | ||
spinner: { | ||
abstract: (strength: number) => Spinner | undefined; | ||
silent: () => Spinner | undefined; | ||
debug: () => Spinner | undefined; | ||
log: () => Spinner | undefined; | ||
warn: () => Spinner | undefined; | ||
error: () => Spinner | undefined; | ||
always: () => Spinner | undefined; | ||
}; | ||
} | ||
export default Logger; |
import Pioppo from "pioppo"; | ||
import { color } from "specialist"; | ||
import Spinner from "tiny-spinner"; | ||
import { resolve } from "./utils.js"; | ||
@@ -63,2 +64,27 @@ class Logger { | ||
}; | ||
this.spinner = { | ||
abstract: (strength) => { | ||
if (strength < this.strength) | ||
return; | ||
return new Spinner(); | ||
}, | ||
silent: () => { | ||
return this.spinner.abstract(0); | ||
}, | ||
debug: () => { | ||
return this.spinner.abstract(1); | ||
}, | ||
log: () => { | ||
return this.spinner.abstract(2); | ||
}, | ||
warn: () => { | ||
return this.spinner.abstract(3); | ||
}, | ||
error: () => { | ||
return this.spinner.abstract(4); | ||
}, | ||
always: () => { | ||
return this.spinner.abstract(Infinity); | ||
}, | ||
}; | ||
this.level = level; | ||
@@ -65,0 +91,0 @@ this.strength = this.levels.indexOf(level); |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"type": "module", | ||
@@ -39,2 +39,3 @@ "bin": { | ||
"tiny-readdir-glob": "^1.0.4", | ||
"tiny-spinner": "^2.0.3", | ||
"worktank": "^2.5.2", | ||
@@ -41,0 +42,0 @@ "zeptomatch": "^1.2.2" |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
70560
1592
14
1
+ Addedtiny-spinner@^2.0.3
+ Addedansi-truncate@1.1.2(transitive)
+ Addedstdin-blocker@2.0.0(transitive)
+ Addedtiny-cursor@2.0.0(transitive)
+ Addedtiny-spinner@2.0.4(transitive)
+ Addedtiny-truncate@1.0.2(transitive)