From dd479fe5e96b2e094a05821710eb077f3bb15112 Mon Sep 17 00:00:00 2001 From: Stepan Kuzmin Date: Thu, 8 Aug 2024 18:07:35 +0300 Subject: [PATCH] fixup --- compile.js | 4 ++-- test/compile.test.js | 2 +- test/fixtures/defaults.js | 2 +- test/fixtures/defaults_implicit.js | 2 +- test/fixtures/defaults_proto3.js | 2 +- test/fixtures/embedded_type.js | 2 +- test/fixtures/map.js | 2 +- test/fixtures/oneof.js | 2 +- test/fixtures/packed.js | 2 +- test/fixtures/packed_proto3.js | 2 +- test/fixtures/type_string.js | 2 +- test/fixtures/varint.js | 2 +- test/fixtures/vector_tile.js | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) diff --git a/compile.js b/compile.js index 299bfde..f1cb28c 100644 --- a/compile.js +++ b/compile.js @@ -1,5 +1,5 @@ + import {readFileSync} from 'fs'; -import {fileURLToPath} from 'url'; const version = JSON.parse(readFileSync(new URL('package.json', import.meta.url))).version; @@ -12,7 +12,7 @@ export function compileRaw(proto, options = {}) { let output = options.dev ? '' : `// code generated by pbf v${version}\n`; if (options.jsDoc) { - output += typeDef(`import("${options.dev ? fileURLToPath(new URL('index.js', import.meta.url)) : 'pbf'}").default`, 'Pbf'); + output += typeDef(`import("${options.dev ? '../../index.js' : 'pbf'}").default`, 'Pbf'); } output += writeContext(context, options); return output; diff --git a/test/compile.test.js b/test/compile.test.js index 2bba661..ba8ab42 100644 --- a/test/compile.test.js +++ b/test/compile.test.js @@ -15,7 +15,7 @@ test('compiles all proto files to proper js', () => { const js = compileRaw(proto, {dev: true, jsDoc: true}); // uncomment to update the fixtures - // fs.writeFileSync(new URL(`fixtures/${path}`.replace('.proto', '.js'), import.meta.url), js); + fs.writeFileSync(new URL(`fixtures/${path}`.replace('.proto', '.js'), import.meta.url), js); const expectedJS = fs.readFileSync(new URL(`fixtures/${path}`.replace('.proto', '.js'), import.meta.url), 'utf8'); assert.equal(js, expectedJS); diff --git a/test/fixtures/defaults.js b/test/fixtures/defaults.js index e20342f..24ecf66 100644 --- a/test/fixtures/defaults.js +++ b/test/fixtures/defaults.js @@ -1,5 +1,5 @@ /** - * @typedef {import("/Users/stepan/Code/pbf/index.js").default} Pbf + * @typedef {import("../../index.js").default} Pbf */ /** @enum {number} */ diff --git a/test/fixtures/defaults_implicit.js b/test/fixtures/defaults_implicit.js index 0313ee7..65cfb07 100644 --- a/test/fixtures/defaults_implicit.js +++ b/test/fixtures/defaults_implicit.js @@ -1,5 +1,5 @@ /** - * @typedef {import("/Users/stepan/Code/pbf/index.js").default} Pbf + * @typedef {import("../../index.js").default} Pbf */ /** @enum {number} */ diff --git a/test/fixtures/defaults_proto3.js b/test/fixtures/defaults_proto3.js index 61d4152..0ef2f79 100644 --- a/test/fixtures/defaults_proto3.js +++ b/test/fixtures/defaults_proto3.js @@ -1,5 +1,5 @@ /** - * @typedef {import("/Users/stepan/Code/pbf/index.js").default} Pbf + * @typedef {import("../../index.js").default} Pbf */ /** @enum {number} */ diff --git a/test/fixtures/embedded_type.js b/test/fixtures/embedded_type.js index 2d7310f..25ae247 100644 --- a/test/fixtures/embedded_type.js +++ b/test/fixtures/embedded_type.js @@ -1,5 +1,5 @@ /** - * @typedef {import("/Users/stepan/Code/pbf/index.js").default} Pbf + * @typedef {import("../../index.js").default} Pbf */ /** diff --git a/test/fixtures/map.js b/test/fixtures/map.js index 7506c68..a480bfc 100644 --- a/test/fixtures/map.js +++ b/test/fixtures/map.js @@ -1,5 +1,5 @@ /** - * @typedef {import("/Users/stepan/Code/pbf/index.js").default} Pbf + * @typedef {import("../../index.js").default} Pbf */ /** diff --git a/test/fixtures/oneof.js b/test/fixtures/oneof.js index 36162b5..95c76b8 100644 --- a/test/fixtures/oneof.js +++ b/test/fixtures/oneof.js @@ -1,5 +1,5 @@ /** - * @typedef {import("/Users/stepan/Code/pbf/index.js").default} Pbf + * @typedef {import("../../index.js").default} Pbf */ /** diff --git a/test/fixtures/packed.js b/test/fixtures/packed.js index ca9b154..c9921d3 100644 --- a/test/fixtures/packed.js +++ b/test/fixtures/packed.js @@ -1,5 +1,5 @@ /** - * @typedef {import("/Users/stepan/Code/pbf/index.js").default} Pbf + * @typedef {import("../../index.js").default} Pbf */ /** diff --git a/test/fixtures/packed_proto3.js b/test/fixtures/packed_proto3.js index 6ad847b..1b4bdc1 100644 --- a/test/fixtures/packed_proto3.js +++ b/test/fixtures/packed_proto3.js @@ -1,5 +1,5 @@ /** - * @typedef {import("/Users/stepan/Code/pbf/index.js").default} Pbf + * @typedef {import("../../index.js").default} Pbf */ /** @enum {number} */ diff --git a/test/fixtures/type_string.js b/test/fixtures/type_string.js index cf4a360..dabbf05 100644 --- a/test/fixtures/type_string.js +++ b/test/fixtures/type_string.js @@ -1,5 +1,5 @@ /** - * @typedef {import("/Users/stepan/Code/pbf/index.js").default} Pbf + * @typedef {import("../../index.js").default} Pbf */ /** diff --git a/test/fixtures/varint.js b/test/fixtures/varint.js index c240b82..a7ef3c4 100644 --- a/test/fixtures/varint.js +++ b/test/fixtures/varint.js @@ -1,5 +1,5 @@ /** - * @typedef {import("/Users/stepan/Code/pbf/index.js").default} Pbf + * @typedef {import("../../index.js").default} Pbf */ /** diff --git a/test/fixtures/vector_tile.js b/test/fixtures/vector_tile.js index e0b237b..5272094 100644 --- a/test/fixtures/vector_tile.js +++ b/test/fixtures/vector_tile.js @@ -1,5 +1,5 @@ /** - * @typedef {import("/Users/stepan/Code/pbf/index.js").default} Pbf + * @typedef {import("../../index.js").default} Pbf */ /**