From b72bb4b771a2435e8b638fa243bb3a927a4dad03 Mon Sep 17 00:00:00 2001 From: Michael Makarov Date: Wed, 30 Oct 2019 17:08:20 +0200 Subject: [PATCH] fix(cli): ionic repair fails if package-lock.json don't exists. (#4196) --- packages/ionic/src/commands/repair.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/ionic/src/commands/repair.ts b/packages/ionic/src/commands/repair.ts index 5f78fb7bfa..01306ff61e 100644 --- a/packages/ionic/src/commands/repair.ts +++ b/packages/ionic/src/commands/repair.ts @@ -1,5 +1,5 @@ import { prettyPath } from '@ionic/cli-framework/utils/format'; -import { remove, unlink } from '@ionic/utils-fs'; +import { pathExists, remove, unlink } from '@ionic/utils-fs'; import * as path from 'path'; import { CommandInstanceInfo, CommandLineInputs, CommandLineOptions, CommandMetadata, IProject, ProjectIntegration } from '../definitions'; @@ -104,7 +104,11 @@ For Cordova apps, it removes and recreates the generated native project and the const nodeModulesDir = path.resolve(project.directory, 'node_modules'); tasks.next(`Removing ${strong(prettyPath(packageLockFile))}`); - await unlink(packageLockFile); + const packageLockFileExists = await pathExists(packageLockFile); + + if (packageLockFileExists) { + await unlink(packageLockFile); + } tasks.next(`Removing ${strong(prettyPath(nodeModulesDir))}`); await remove(nodeModulesDir);