Skip to content

Commit

Permalink
fix: check file exists before update (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoppippi authored Aug 22, 2024
1 parent e93efe8 commit cf52671
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/update-files.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as path from 'node:path'
import { existsSync } from 'node:fs'
import { readJsoncFile, readTextFile, writeJsoncFile, writeTextFile } from './fs'
import { isManifest, isPackageLockManifest } from './manifest'
import type { Operation } from './operation'
Expand Down Expand Up @@ -36,6 +37,10 @@ export async function updateFiles(operation: Operation): Promise<Operation> {
* @returns - `true` if the file was actually modified
*/
async function updateFile(relPath: string, operation: Operation): Promise<boolean> {
if (!existsSync(relPath)) {
return false
}

const name = path.basename(relPath).trim().toLowerCase()

switch (name) {
Expand Down

0 comments on commit cf52671

Please sign in to comment.