From 3dae4ca04186ab0fc45aad3d2651ed284134dc23 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Tue, 8 Dec 2020 09:31:56 -0800 Subject: [PATCH] build: fix build error with stylelint paths To run node binaries, our build scripts parse the package.json file from a node module to find the path to its bin files. Instead of this: "bin": { "stylelint": "path/to/stylelint.js" }, I found this: "bin": "path/to/stylelint.js" Now we accept both formats. I'm not sure why/how/when this changed, or if it has to do with our fork of stylelint. Change-Id: I5b804c5e90186195ad5d60536e200eb83c42e801 --- build/shakaBuildHelpers.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/build/shakaBuildHelpers.py b/build/shakaBuildHelpers.py index e51e8105dc..01384757a6 100644 --- a/build/shakaBuildHelpers.py +++ b/build/shakaBuildHelpers.py @@ -294,7 +294,16 @@ def get_node_binary(module_name, bin_name=None): if os.path.isdir(path): json_path = os.path.join(path, 'package.json') package_data = json.load(open_file(json_path, 'r')) - bin_path = os.path.join(path, package_data['bin'][bin_name]) + bin_data = package_data['bin'] + + if type(bin_data) is str or type(bin_data) is unicode: + # There's only one binary here. + bin_rel_path = bin_data + else: + # It's a dictionary, so look up the specific binary we want. + bin_rel_path = bin_data[bin_name] + + bin_path = os.path.join(path, bin_rel_path) return ['node', bin_path] # Not found locally, assume it can be found in os.environ['PATH'].