diff options
author | Josh Haberman <jhaberman@gmail.com> | 2016-06-16 11:59:08 -0700 |
---|---|---|
committer | Feng Xiao <xfxyjwf@gmail.com> | 2016-06-17 11:25:02 -0700 |
commit | a0f490370c49106cb68b704a3dd12ea6d0de83d8 (patch) | |
tree | 89f4560d60c54e8d928b710f991ccb0cddd1f6c4 /src/google | |
parent | 343363aa6cec41aaccaff47b9faabe5c12e79227 (diff) | |
download | protobuf-a0f490370c49106cb68b704a3dd12ea6d0de83d8.tar.gz protobuf-a0f490370c49106cb68b704a3dd12ea6d0de83d8.tar.bz2 protobuf-a0f490370c49106cb68b704a3dd12ea6d0de83d8.zip |
JS: import well-known types from google-protobuf package.
Diffstat (limited to 'src/google')
-rwxr-xr-x | src/google/protobuf/compiler/js/js_generator.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc index 3de61e80..5d1ba598 100755 --- a/src/google/protobuf/compiler/js/js_generator.cc +++ b/src/google/protobuf/compiler/js/js_generator.cc @@ -160,6 +160,14 @@ 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) { + // 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 + // their own npm packages. + return "google-protobuf/"; + } + size_t slashes = std::count(filename.begin(), filename.end(), '/'); if (slashes == 0) { return "./"; |