From 41d9cf102c0723722a9a9549301764d6b9eb3127 Mon Sep 17 00:00:00 2001 From: trickypr Date: Fri, 12 Nov 2021 17:46:06 +1100 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20Better=20status=20command=20outp?= =?UTF-8?q?ut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/status.ts | 28 +++++++++++++++++++++++----- src/utils/config.ts | 6 +++++- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/commands/status.ts b/src/commands/status.ts index c075df4..f23a952 100644 --- a/src/commands/status.ts +++ b/src/commands/status.ts @@ -1,12 +1,30 @@ import { existsSync } from 'fs' import { log } from '..' import { ENGINE_DIR } from '../constants' -import { dispatch } from '../utils' +import { dispatch, hasConfig } from '../utils' -export const status = async () => { - if (existsSync(ENGINE_DIR)) { - dispatch('git', ['status'], ENGINE_DIR, true) +export const status = async (): Promise => { + const configExists = hasConfig() + const engineExists = existsSync(ENGINE_DIR) + + if (!configExists && !engineExists) { + log.info( + "Melon doesn't appear to be setup for this project. You can set it up by running |melon setup-project|" + ) + + return + } + + if (engineExists) { + log.info("The following changes have been made to firefox's source code") + await dispatch('git', ['status'], ENGINE_DIR, true) + + return } else { - log.error(`Unable to locate src directory.`) + log.info( + "It appears that melon has been configured, but you haven't run |melon download|" + ) + + return } } diff --git a/src/utils/config.ts b/src/utils/config.ts index 345b13f..bece3ce 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -73,8 +73,12 @@ const defaultConfig: Config = { }, } +export function hasConfig(): boolean { + return existsSync(configPath) +} + export function getConfig(): Config { - const configExists = existsSync(configPath) + const configExists = hasConfig() let fileContents = '{}' let fileParsed: Config