Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Commit

Permalink
Update method name
Browse files Browse the repository at this point in the history
  • Loading branch information
mgechev committed Jan 15, 2019
1 parent 93b834f commit cc1a219
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 24 deletions.
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,6 @@ local_repository(
)

local_repository(
name = "devserver_test_workspace",
path = "devserver/devserver/test/test-workspace",
)
name = "devserver_test_workspace",
path = "devserver/devserver/test/test-workspace",
)
8 changes: 4 additions & 4 deletions devserver/devserver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = ["devserver.go"],
importpath = "github.com/bazelbuild/rules_typescript/devserver/devserver",
visibility = ["//visibility:public"],
deps = [
"//devserver/utils:go_default_library",
],
importpath = "github.com/bazelbuild/rules_typescript/devserver/devserver",
visibility = ["//visibility:public"],
)

go_test(
name = "go_default_test",
srcs = ["devserver_test.go"],
embed = [":go_default_library"],
# Required runfiles for the devserver tests.
data = [
"test/index.html",
"test/relative.html",
"@devserver_test_workspace//:sources",
]
],
embed = [":go_default_library"],
)
4 changes: 2 additions & 2 deletions devserver/utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["runfile.go"],
importpath = "github.com/bazelbuild/rules_typescript/devserver/utils",
visibility = ["//visibility:public"],
deps = [
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
],
importpath = "github.com/bazelbuild/rules_typescript/devserver/utils",
visibility = ["//visibility:public"],
)
9 changes: 6 additions & 3 deletions devserver/utils/runfile.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Package utils provides utility functions used in devserver.
package utils

import "github.com/bazelbuild/rules_go/go/tools/bazel"

// Runfile resolves the real path of a specified runfile path.
// This method is used to resolve incompatibility between
// external and g3.
func Runfile(path string) (string, error) {
// FOR G3:
// return path, nil
return bazel.Runfile(path)
var err error
path, err = bazel.Runfile(path)
return path, err
}
4 changes: 2 additions & 2 deletions examples/devserver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ ts_library(

ts_devserver(
name = "devserver",
port = 80,
serving_path = "/bundle.js",
additional_root_paths = [
"npm/node_modules/tslib",
"build_bazel_rules_typescript/examples/devserver/",
],
port = 80,
serving_path = "/bundle.js",
static_files = [
# Files you want to import from the "additional_root_paths", still need to be explicitly specified
# as files that should be served. The root paths just make it more convenient to import those dependencies.
Expand Down
25 changes: 25 additions & 0 deletions examples/protocol_buffers/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
load("@build_bazel_rules_nodejs//:defs.bzl", "http_server", "rollup_bundle")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load(
"//:defs.bzl",
"ts_devserver",
Expand Down Expand Up @@ -111,3 +113,26 @@ ts_library(
"@npm//protractor",
],
)

proto_library(
name = "rules_typescript_proto",
srcs = [
"car.proto",
"tire.proto",
],
visibility = ["//visibility:public"],
)

go_proto_library(
name = "rules_typescript_go_proto",
importpath = "github.com/bazelbuild/rules_typescript/examples/protocol_buffers",
proto = ":rules_typescript_proto",
visibility = ["//visibility:public"],
)

go_library(
name = "go_default_library",
embed = [":rules_typescript_go_proto"],
importpath = "github.com/bazelbuild/rules_typescript/examples/protocol_buffers",
visibility = ["//visibility:public"],
)
1 change: 0 additions & 1 deletion internal/common/module_mappings.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def _get_deps(attrs, names):
# Traverse 'srcs' in addition so that we can go across a genrule
_MODULE_MAPPINGS_DEPS_NAMES = ["deps", "srcs", "_helpers"]


_DEBUG = False

def debug(msg, values = ()):
Expand Down
18 changes: 9 additions & 9 deletions internal/devserver/ts_devserver.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ def _ts_devserver(ctx):

# Avoid writing non-normalized paths (workspace/../other_workspace/path)
if ctx.executable._devserver.short_path.startswith("../"):
script_path = ctx.executable._devserver.short_path[len("../"):]
script_path = ctx.executable._devserver.short_path[len("../"):]
else:
script_path = "/".join([
ctx.workspace_name,
ctx.executable._devserver.short_path,
])
script_path = "/".join([
ctx.workspace_name,
ctx.executable._devserver.short_path,
])

substitutions = {
"TEMPLATED_entry_module": ctx.attr.entry_module,
Expand All @@ -121,10 +121,10 @@ def _ts_devserver(ctx):
"TEMPLATED_workspace": workspace_name,
}
ctx.actions.expand_template(
template=ctx.file._launcher_template,
output=ctx.outputs.script,
substitutions=substitutions,
is_executable=True,
template = ctx.file._launcher_template,
output = ctx.outputs.script,
substitutions = substitutions,
is_executable = True,
)

return [DefaultInfo(
Expand Down

0 comments on commit cc1a219

Please sign in to comment.