v12 preparations: Add feature switch for project directory validation

Connects-to: #1770
Change-type: patch
This commit is contained in:
Paulo Castro 2020-05-29 21:58:44 +01:00
parent fcc13f9476
commit 2ab8ae1c10
2 changed files with 21 additions and 11 deletions

View File

@ -562,10 +562,15 @@ export async function validateProjectDirectory(
checkCompose(path.join(opts.projectPath, '..')), checkCompose(path.join(opts.projectPath, '..')),
]); ]);
if (!hasCompose && hasParentCompose) { if (!hasCompose && hasParentCompose) {
Logger.getLogger().logWarn(stripIndent` const { isV12 } = await import('./version');
"docker-compose.y[a]ml" file found in parent directory: please check const msg = stripIndent`
that the correct folder was specified. (Suppress with '--noparent-check'.) "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);
}
} }
} }
} }

View File

@ -500,13 +500,18 @@ describe('balena push: project validation', function() {
'basic', 'basic',
'service1', 'service1',
); );
const expectedErrorLines = [ const expectedErrorLines = isV12()
'The --nolive flag is only valid when pushing to a local mode device', ? [
]; 'Error: "docker-compose.y[a]ml" file found in parent directory: please check that',
const expectedOutputLines = [ "the correct source folder was specified. (Suppress with '--noparent-check'.)",
'[Warn] "docker-compose.y[a]ml" file found in parent directory: please check', ]
"[Warn] that the correct 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( const { out, err } = await runCommand(
`push testApp --source ${projectPath} --nolive`, `push testApp --source ${projectPath} --nolive`,