Skip to content

Commit

Permalink
chore: lint and cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianwessel committed Aug 30, 2024
1 parent 31ff173 commit 98f69f7
Showing 3 changed files with 12 additions and 9 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -21,6 +21,11 @@ jobs:
id: checkout
uses: actions/checkout@v4

- name: Setup Biome
uses: biomejs/setup-biome@v2
with:
version: latest

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
@@ -32,9 +37,8 @@ jobs:
id: npm-ci
run: npm ci

- name: Lint
id: npm-lint
run: npm run lint
- name: Run Biome
run: biome ci .

- name: Test
id: npm-ci-test
7 changes: 4 additions & 3 deletions src/database/db.ts
Original file line number Diff line number Diff line change
@@ -32,7 +32,8 @@ async function startSurrealDBContainer(config: Config): Promise<StartedTestConta
if (error instanceof Error) {
if (error.message.includes('pull access denied') || error.message.includes('not found')) {
throw new Error(`Invalid or inaccessible Docker image: ${config.surrealImage}`)
} else if (error.message.includes('connection refused')) {
}
if (error.message.includes('connection refused')) {
throw new Error('Unable to connect to Docker daemon. Is Docker running?')
}
}
@@ -44,8 +45,8 @@ export const connectDb = async (config: Config, createInstance = false) => {
if (createInstance) {
try {
container = await startSurrealDBContainer(config)
} catch (error: any) {
console.error('Error starting SurrealDB container:', error.message)
} catch (error) {
console.error('Error starting SurrealDB container:', error instanceof Error ? error.message : error)
throw error // Re-throw to be caught by the caller if needed
}
}
4 changes: 1 addition & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ const main = async () => {
.version('1.0.0')

program
.option('-f, --schemaFile [schemaFile]', 'a SurrealQL file containing the definitions', )
.option('-f, --schemaFile [schemaFile]', 'a SurrealQL file containing the definitions')
.option('-c, --config [config]', 'config file', 'surql-gen.json')
.option('-s, --surreal [surreal]', 'SurrealDB connection url', 'http://localhost:8000')
.option('-u, --username [username]', 'auth username', 'root')
@@ -64,8 +64,6 @@ const main = async () => {

const config = configFileSchema.parse({ ...options, ...fileContent })

console.log("config", config)

try {
if (config.schemaFile) {
await connectDb(config, true)

0 comments on commit 98f69f7

Please sign in to comment.