yaml-verify
Advanced tools
Comparing version 1.0.8 to 1.0.9
{ | ||
"name": "yaml-verify", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "A CLI utility to ensure proper formatting of YAML files.", |
#!/usr/bin/env node | ||
import fs from 'fs' | ||
import { promisify } from 'util' | ||
import chalk from 'chalk' | ||
@@ -10,6 +9,4 @@ import { program } from 'commander' | ||
import ora from 'ora' | ||
const fsPromises = fs.promises | ||
const readFileAsync = promisify(fs.readFile) | ||
const startTime = process.hrtime(); // Capture the start time | ||
const startTime = new Date() // Capture the start time | ||
@@ -86,3 +83,3 @@ let validationFailed = false // Flag to track any validation failure | ||
try { | ||
const fileContents = await readFileAsync(file, 'utf8') | ||
const fileContents = await fs.promises.readFile(file, 'utf8') | ||
const data = yaml.load(fileContents) | ||
@@ -102,3 +99,3 @@ const errors = checkForDuplicates(data) | ||
const results = [] | ||
const spinner = ora('Validating YAML files...').start(); // Start the spinner | ||
const spinner = ora('Validating YAML files...').start() // Start the spinner | ||
@@ -143,3 +140,3 @@ while (index < files.length) { | ||
let allFilesPromises = filePaths.map(async (filePath) => { | ||
const stat = await fsPromises.stat(filePath) | ||
const stat = await fs.promises.stat(filePath) | ||
if (stat.isDirectory()) { | ||
@@ -159,5 +156,6 @@ return findYamlFilesAsync(filePath) | ||
const [seconds, nanoseconds] = process.hrtime(startTime); | ||
const elapsed = (seconds + nanoseconds / 1e9).toFixed(2); // Convert to seconds and format | ||
console.log(`\nTotal execution time: ${elapsed} seconds.`); | ||
// Execution of some code... | ||
const endTime = new Date() // Capture the end time | ||
const elapsed = (endTime - startTime) / 1000 // Calculate the elapsed time in seconds | ||
console.log(`Total execution time: ${elapsed.toFixed(2)} seconds.`) | ||
@@ -164,0 +162,0 @@ // Check the flag and exit with status code 1 if any validation failed |
10169
168