diff --git a/src/commands/environment/copy-example-files.ts b/src/commands/environment/copy-example-files.ts index 1c17788..c6579f2 100644 --- a/src/commands/environment/copy-example-files.ts +++ b/src/commands/environment/copy-example-files.ts @@ -1,13 +1,20 @@ import { Command } from 'commander' import { projectConfig } from '../../config/project.config' -import { copyFile, readPathMatchingFiles } from '../../utils/file-system' +import { copyFile, isDirectory, readPathMatchingFiles } from '../../utils/file-system' +import logger from '../../utils/log' export function copyExampleFilesCommand() { return new Command() .name('copy-example-files') - .summary('Copy example dotenv files on each repo path') + .summary('Copy example dotenv (.env.example) files on each repo path') .action(() => { for (const path of projectConfig.reposPaths()) { + if (!isDirectory(path)) { + logger.error(`The repository path '${path}' does not yet exist.`) + logger.error('Did you run `dems setup` or `dems git clone`?') + process.exit(1); + } + const exampleEnvFiles = readPathMatchingFiles(path, '.env.example') if (exampleEnvFiles.length > 0) { @@ -17,6 +24,10 @@ export function copyExampleFilesCommand() { target: file.replace('.example', ''), }) } + } else { + logger.error(`No example env files were found in path: '${path}'`) + logger.error('Current example files in scope: [.env.example]') + process.exit(1) } } }) diff --git a/src/commands/setup/index.ts b/src/commands/setup/index.ts index 34e3c49..31499d3 100644 --- a/src/commands/setup/index.ts +++ b/src/commands/setup/index.ts @@ -1,11 +1,11 @@ import { Command } from 'commander' +import logger from '../../utils/log' import { composeCommand } from '../compose' import { depsCopyCommand } from '../dependencies/copy' import { copyExampleFilesCommand } from '../environment/copy-example-files' import { generateDotEnvCommand } from '../environment/generate-dot-env' import { gitCloneCommand } from '../git/clone' import { createProjectCommand } from '../project/create' -import logger from '../../utils/log' export function setupCommand() { return new Command()