Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
0e27112c
Commit
0e27112c
authored
Jun 16, 2016
by
Josh Haberman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix: base the require logic on the file being required.
parent
13374867
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
js_generator.cc
src/google/protobuf/compiler/js/js_generator.cc
+4
-4
No files found.
src/google/protobuf/compiler/js/js_generator.cc
View file @
0e27112c
...
...
@@ -159,8 +159,8 @@ string GetJSFilename(const string& filename) {
// Given a filename like foo/bar/baz.proto, returns the root directory
// path ../../
string
GetRootPath
(
const
string
&
filename
)
{
if
(
filename
.
find
(
"google/protobuf"
)
==
0
)
{
string
GetRootPath
(
const
string
&
f
rom_filename
,
const
string
&
to_f
ilename
)
{
if
(
to_
filename
.
find
(
"google/protobuf"
)
==
0
)
{
// Well-known types (.proto files in the google/protobuf directory) are
// assumed to come from the 'google-protobuf' npm package. We may want to
// generalize this exception later by letting others put generated code in
...
...
@@ -168,7 +168,7 @@ string GetRootPath(const string& filename) {
return
"google-protobuf/"
;
}
size_t
slashes
=
std
::
count
(
f
ilename
.
begin
(),
filename
.
end
(),
'/'
);
size_t
slashes
=
std
::
count
(
f
rom_filename
.
begin
(),
from_
filename
.
end
(),
'/'
);
if
(
slashes
==
0
)
{
return
"./"
;
}
...
...
@@ -2846,7 +2846,7 @@ void Generator::GenerateFile(const GeneratorOptions& options,
printer
->
Print
(
"var $alias$ = require('$file$');
\n
"
,
"alias"
,
ModuleAlias
(
name
),
"file"
,
GetRootPath
(
file
->
name
())
+
GetJSFilename
(
name
));
"file"
,
GetRootPath
(
file
->
name
()
,
name
)
+
GetJSFilename
(
name
));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment