Skip to content

Commit

Permalink
fix: catch more runtime errors
Browse files Browse the repository at this point in the history
  • Loading branch information
soedirgo committed Apr 1, 2021
1 parent 1d73e9d commit ce0efda
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/commands/eject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ export default {
},
})
)
)
).catch(() => {
spinner.fail('Error writing Docker setup files.')
process.exit(1)
})

spinner.succeed('Supabase Docker ejected.')
},
Expand Down
10 changes: 8 additions & 2 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,17 @@ export default {
},
})
)
)
).catch(() => {
spinner.fail('Error writing Docker setup files.')
process.exit(1)
})

await run(
'docker-compose --file .supabase/docker/docker-compose.yml --project-name supabase build --no-cache --parallel --quiet'
)
).catch(() => {
spinner.fail('Error running docker-compose.')
process.exit(1)
})

spinner.succeed('Project initialized.')
fancy(`Supabase URL: ${highlight(`http://localhost:${kongPort}`)}
Expand Down
20 changes: 17 additions & 3 deletions src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,37 @@ import { GluegunToolbox } from 'gluegun'
export default {
name: 'start',
run: async ({
filesystem: { exists },
print: {
colors: { highlight },
error,
spin,
},
system: { run, which },
}: GluegunToolbox) => {
const spinner = spin('Starting local Supabase...')
if (!exists('.supabase')) {
error(
`Cannot find ${highlight(
'.supabase'
)} in the current directory. Perhaps you meant to run ${highlight('supabase init')} first?`
)
process.exit(1)
}

const dockerCompose = which('docker-compose')
if (!dockerCompose) {
spinner.fail(`Cannot find ${highlight('docker-compose')} executable in PATH.`)
error(`Cannot find ${highlight('docker-compose')} executable in PATH.`)
process.exit(1)
}

const spinner = spin('Starting local Supabase...')

await run(
'docker-compose --file .supabase/docker/docker-compose.yml --project-name supabase up --detach'
)
).catch(() => {
spinner.fail('Error running docker-compose.')
process.exit(1)
})

spinner.succeed('Started local Supabase.')
},
Expand Down
20 changes: 17 additions & 3 deletions src/commands/stop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,37 @@ import { GluegunToolbox } from 'gluegun'
export default {
name: 'stop',
run: async ({
filesystem: { exists },
print: {
colors: { highlight },
error,
spin,
},
system: { run, which },
}: GluegunToolbox) => {
const spinner = spin('Stopping local Supabase...')
if (!exists('.supabase')) {
error(
`Cannot find ${highlight(
'.supabase'
)} in the current directory. Perhaps you meant to run ${highlight('supabase init')} first?`
)
process.exit(1)
}

const dockerCompose = which('docker-compose')
if (!dockerCompose) {
spinner.fail(`Cannot find ${highlight('docker-compose')} executable in PATH.`)
error(`Cannot find ${highlight('docker-compose')} executable in PATH.`)
process.exit(1)
}

const spinner = spin('Stopping local Supabase...')

await run(
'docker-compose --file .supabase/docker/docker-compose.yml --project-name supabase down'
)
).catch(() => {
spinner.fail('Error running docker-compose.')
process.exit(1)
})

spinner.succeed('Stopped local Supabase.')
},
Expand Down

0 comments on commit ce0efda

Please sign in to comment.