From ea67a603dd32287653b4bac1c7ea1730598d31e8 Mon Sep 17 00:00:00 2001 From: Vaibhav Singh Date: Wed, 4 Aug 2021 18:19:43 +0530 Subject: [PATCH] fix: e2e folder deleted permanently (#11) --- src/schematics/nightwatch/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/schematics/nightwatch/index.ts b/src/schematics/nightwatch/index.ts index 1dc8dc9..2887531 100644 --- a/src/schematics/nightwatch/index.ts +++ b/src/schematics/nightwatch/index.ts @@ -229,12 +229,12 @@ function removeFiles(): Rule { function deleteDirectory(tree: Tree, path: string): void { try { - tree.delete(path); - } catch (error) { - if (/does not exist/.test(error)) { - console.warn("⚠️ Skipping deletion: e2e/ directory doesn't exist"); + if (tree.getDir(path).subfiles.length > 0 || tree.getDir(path).subdirs.length > 0) { + tree.rename('e2e', `protractor/${path}`); + } else { + console.warn(`⚠️ Skipping deletion: ${path} doesn't exist`); } - } + } catch (error) {} } export const removeE2ELinting = (tree: Tree, angularJsonVal: any, project: string) => {