Skip to content

Commit

Permalink
build: fix build error with stylelint paths
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joeyparrish committed Dec 8, 2020
1 parent 56bb045 commit 3dae4ca
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion build/shakaBuildHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'].
Expand Down

0 comments on commit 3dae4ca

Please sign in to comment.