Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Commit

Permalink
πŸ’„ Better status command output
Browse files Browse the repository at this point in the history
  • Loading branch information
trickypr committed Nov 12, 2021
1 parent f1d2b50 commit 41d9cf1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
28 changes: 23 additions & 5 deletions src/commands/status.ts
Original file line number Diff line number Diff line change
@@ -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<void> => {
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
}
}
6 changes: 5 additions & 1 deletion src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 41d9cf1

Please sign in to comment.