Skip to content

Commit

Permalink
Bugfix/msi 709 serverless no color on tty (#1570)
Browse files Browse the repository at this point in the history
* Initial add of VSCode Dev Container

* Potential fix for Serverless #1464

* Reverting T201 fix now that flake8-print is fixed

* Fixing spelling issue
  • Loading branch information
jake-skipper committed Sep 1, 2022
1 parent 16dd031 commit 72eeb8b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
18 changes: 16 additions & 2 deletions runway/module/serverless.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,24 @@ def gen_cmd(self, command: str, args_list: Optional[List[str]] = None) -> List[s
"""
args = [command] + self.cli_args + self.options.args
args.extend(args_list or [])
if self.ctx.no_color and "--no-color" not in args:
args.append("--no-color")
if command not in ["remove", "package", "print"] and self.ctx.is_noninteractive:
args.append("--conceal") # hide secrets from serverless output

# Serverless is no longer happy using "--no-color" arg.
# It was never natively supported by the app, only by an
# upstream dependency called "chalk" that it uses. Later
# versions of Serverless now break with "--no-color"
# defined. This update disables Serverless color in a way
# now recommended by the developers, see the following issue:
# https://github.com/serverless/serverless/issues/11142
if self.ctx.no_color:
return generate_node_command(
command="FORCE_COLOR=0 sls",
command_opts=args,
path=self.path,
logger=self.logger,
)

return generate_node_command(
command="sls", command_opts=args, path=self.path, logger=self.logger
)
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/module/test_serverless.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,14 @@ def test_gen_cmd(

obj.ctx.env.vars["CI"] = "1"
mocker.patch.object(runway_context, "no_color", True)
expected_opts.append("--no-color")
if command not in ["remove", "print"]:
expected_opts.append("--conceal")
assert obj.gen_cmd(command, args_list=["--extra-arg"]) == ["success"]
mock_cmd.assert_called_once_with(
command="sls", command_opts=expected_opts, logger=obj.logger, path=tmp_path
command="FORCE_COLOR=0 sls",
command_opts=expected_opts,
logger=obj.logger,
path=tmp_path,
)

def test_init(
Expand Down

0 comments on commit 72eeb8b

Please sign in to comment.