Skip to content

Commit

Permalink
chore: adjust example loader dirname
Browse files Browse the repository at this point in the history
  • Loading branch information
chakhsu committed Feb 5, 2024
1 parent ca78987 commit 8d66fdf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 21 deletions.
9 changes: 2 additions & 7 deletions example/asyncStream/loader.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import path from 'node:path'
import { ProtoLoader } from '../../lib/index.js'
// same as import { ProtoLoader } from 'grpcity'

import path from 'node:path'
import { fileURLToPath } from 'node:url'

// get this file dir path
const __dirname = path.dirname(fileURLToPath(import.meta.url))

export const loader = new ProtoLoader({
location: path.join(__dirname, '../proto'),
location: path.join(path.dirname(new URL(import.meta.url).pathname), '../proto'),
files: ['stream/service.proto']
})
4 changes: 1 addition & 3 deletions example/helloworld/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { ProtoLoader } from '../../lib/index.js'

import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

// get this file dir path
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const __dirname = path.dirname(new URL(import.meta.url).pathname)

export const loader = new ProtoLoader({
location: path.join(__dirname, '../proto'),
Expand Down
5 changes: 1 addition & 4 deletions example/reflection/loader.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { ProtoLoader } from '../../lib/index.js'
// same as import { ProtoLoader } from 'grpcity'

import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

// get this file dir path
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const __dirname = path.dirname(new URL(import.meta.url).pathname)

export const helloworldLoader = new ProtoLoader({
location: path.join(__dirname, '../proto'),
Expand Down
9 changes: 2 additions & 7 deletions example/simple/loader.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import path from 'node:path'
import { ProtoLoader } from '../../lib/index.js'
// same as import { ProtoLoader } from 'grpcity'

import path from 'node:path'
import { fileURLToPath } from 'node:url'

// get this file dir path
const __dirname = path.dirname(fileURLToPath(import.meta.url))

export const loader = new ProtoLoader({
location: path.join(__dirname, './'),
location: path.join(path.dirname(new URL(import.meta.url).pathname), './'),
files: ['service.proto']
})

0 comments on commit 8d66fdf

Please sign in to comment.