Skip to content

Commit

Permalink
Remove pify in favour of node:fsPromises
Browse files Browse the repository at this point in the history
  • Loading branch information
hugihlynsson committed Jan 10, 2025
1 parent 9bb06ae commit 035ac19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 9 additions & 7 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import ora from 'ora';
import chalk from 'chalk';
import { Minimatch } from 'minimatch';
import dateFns from 'date-fns';
import fs from 'fs';
import fs from 'node:fs';
import fsPromises from 'node:fs/promises';
import http from 'http';
import inquirer from 'inquirer';
import jwt from 'jsonwebtoken';
import { loadJsonFile } from 'load-json-file';
import logSymbols from 'log-symbols';
import open from 'open';
import path from 'path';
import pify from 'pify';
import portfinder from 'portfinder';
import querystring from 'querystring';
import got from 'got'; // eslint-disable-line import/no-unresolved
Expand Down Expand Up @@ -1016,7 +1016,8 @@ function loadAvoJsonOrInit({
skipPullMaster,
skipInit,
}): Promise<AvoJson> {
return pify(fs.readFile)('avo.json', 'utf8')
return fsPromises
.readFile('avo.json', 'utf8')
.then((avoFile) => {
if (hasMergeConflicts(avoFile)) {
return resolveAvoJsonConflicts(avoFile, {
Expand Down Expand Up @@ -1477,12 +1478,13 @@ function status(source: string, json, argv: any): void {
results
.filter((result) => !result.startsWith('.git'))
.map((resultPath) =>
pify(fs.lstat)(resultPath)
fsPromises
.lstat(resultPath)
.then((stats) => {
if (stats.isSymbolicLink()) {
return [];
}
return pify(fs.readFile)(resultPath, 'utf8')
return fsPromises.readFile(resultPath, 'utf8')
.then((data) => [resultPath, data])
.catch(() => {
if (argv.verbose) {
Expand All @@ -1503,7 +1505,7 @@ function status(source: string, json, argv: any): void {
.then((cache) => {
sources = Promise.all(
sources.map((source) =>
pify(fs.readFile)(source.path, 'utf8').then((data) => {
fsPromises.readFile(source.path, 'utf8').then((data) => {
const eventMap = getEventMap(data, argv.verbose);
if (eventMap !== null) {
const moduleMap = getModuleMap(data, argv.verbose);
Expand Down Expand Up @@ -2333,7 +2335,7 @@ yargs(hideBin(process.argv)) // eslint-disable-line no-unused-expressions
aliases: ['resolve', 'conflicts'],
desc: 'Resolve git conflicts in Avo files',
handler: (argv) =>
pify(fs.readFile)('avo.json', 'utf8')
fsPromises.readFile('avo.json', 'utf8')
.then((avoFile) => {
if (hasMergeConflicts(avoFile)) {
return requireAuth(argv, () =>
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"node-avo-inspector": "^1.0.1",
"open": "^9.1.0",
"ora": "^6.0.1",
"pify": "^6.0.0",
"portfinder": "^1.0.28",
"semver": "^7.3.7",
"update-notifier": "^6.0.2",
Expand Down

0 comments on commit 035ac19

Please sign in to comment.