From 2ab8ae1c1056b6d4bd77b74d44f778f854ec5955 Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Fri, 29 May 2020 21:58:44 +0100 Subject: [PATCH] v12 preparations: Add feature switch for project directory validation Connects-to: #1770 Change-type: patch --- lib/utils/compose_ts.ts | 13 +++++++++---- tests/commands/push.spec.ts | 19 ++++++++++++------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/utils/compose_ts.ts b/lib/utils/compose_ts.ts index 687c29b7..d75fc8ca 100644 --- a/lib/utils/compose_ts.ts +++ b/lib/utils/compose_ts.ts @@ -562,10 +562,15 @@ export async function validateProjectDirectory( checkCompose(path.join(opts.projectPath, '..')), ]); if (!hasCompose && hasParentCompose) { - Logger.getLogger().logWarn(stripIndent` - "docker-compose.y[a]ml" file found in parent directory: please check - that the correct folder was specified. (Suppress with '--noparent-check'.) - `); + const { isV12 } = await import('./version'); + const msg = stripIndent` + "docker-compose.y[a]ml" file found in parent directory: please check that + the correct source folder was specified. (Suppress with '--noparent-check'.)`; + if (isV12()) { + throw new ExpectedError(`Error: ${msg}`); + } else { + Logger.getLogger().logWarn(msg); + } } } } diff --git a/tests/commands/push.spec.ts b/tests/commands/push.spec.ts index e894b9c2..390bca74 100644 --- a/tests/commands/push.spec.ts +++ b/tests/commands/push.spec.ts @@ -500,13 +500,18 @@ describe('balena push: project validation', function() { 'basic', 'service1', ); - const expectedErrorLines = [ - 'The --nolive flag is only valid when pushing to a local mode device', - ]; - const expectedOutputLines = [ - '[Warn] "docker-compose.y[a]ml" file found in parent directory: please check', - "[Warn] that the correct folder was specified. (Suppress with '--noparent-check'.)", - ]; + const expectedErrorLines = isV12() + ? [ + 'Error: "docker-compose.y[a]ml" file found in parent directory: please check that', + "the correct source folder was specified. (Suppress with '--noparent-check'.)", + ] + : ['The --nolive flag is only valid when pushing to a local mode device']; + const expectedOutputLines = isV12() + ? [] + : [ + '[Warn] "docker-compose.y[a]ml" file found in parent directory: please check that', + "[Warn] the correct source folder was specified. (Suppress with '--noparent-check'.)", + ]; const { out, err } = await runCommand( `push testApp --source ${projectPath} --nolive`,