|
@@ -159,8 +159,8 @@ string GetJSFilename(const string& filename) {
|
|
|
|
|
|
// Given a filename like foo/bar/baz.proto, returns the root directory
|
|
// Given a filename like foo/bar/baz.proto, returns the root directory
|
|
// path ../../
|
|
// path ../../
|
|
-string GetRootPath(const string& filename) {
|
|
|
|
- if (filename.find("google/protobuf") == 0) {
|
|
|
|
|
|
+string GetRootPath(const string& from_filename, const string& to_filename) {
|
|
|
|
+ if (to_filename.find("google/protobuf") == 0) {
|
|
// Well-known types (.proto files in the google/protobuf directory) are
|
|
// Well-known types (.proto files in the google/protobuf directory) are
|
|
// assumed to come from the 'google-protobuf' npm package. We may want to
|
|
// assumed to come from the 'google-protobuf' npm package. We may want to
|
|
// generalize this exception later by letting others put generated code in
|
|
// generalize this exception later by letting others put generated code in
|
|
@@ -168,7 +168,7 @@ string GetRootPath(const string& filename) {
|
|
return "google-protobuf/";
|
|
return "google-protobuf/";
|
|
}
|
|
}
|
|
|
|
|
|
- size_t slashes = std::count(filename.begin(), filename.end(), '/');
|
|
|
|
|
|
+ size_t slashes = std::count(from_filename.begin(), from_filename.end(), '/');
|
|
if (slashes == 0) {
|
|
if (slashes == 0) {
|
|
return "./";
|
|
return "./";
|
|
}
|
|
}
|
|
@@ -2846,7 +2846,7 @@ void Generator::GenerateFile(const GeneratorOptions& options,
|
|
printer->Print(
|
|
printer->Print(
|
|
"var $alias$ = require('$file$');\n",
|
|
"var $alias$ = require('$file$');\n",
|
|
"alias", ModuleAlias(name),
|
|
"alias", ModuleAlias(name),
|
|
- "file", GetRootPath(file->name()) + GetJSFilename(name));
|
|
|
|
|
|
+ "file", GetRootPath(file->name(), name) + GetJSFilename(name));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|