Skip to content

Commit

Permalink
az webapp new - Fix Node.js errors (#74)
Browse files Browse the repository at this point in the history
* Fix list index out of range error

* Fix error if no node version specified in package.json

* Fix bug

* Fix linting errors
  • Loading branch information
anthonychu authored and panchagnula committed Feb 23, 2018
1 parent 542408c commit bfd7a70
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/webapp/azext_webapp/create_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,17 @@ def check_app_exists(cmd, rg_name, app_name):

def get_lang_from_content(src_path):
import glob
# NODE: package.json should exisit in the application root dir
# NETCORE: NETCORE.csproj should exist in the root dir
# NODE: package.json should exist in the application root dir
# NETCORE: *.csproj should exist in the application root dir
runtime_details_dict = dict.fromkeys(['language', 'file_loc', 'default_sku'])
package_json_file = os.path.join(src_path, 'package.json')
package_netcore_file = os.path.join(src_path, glob.glob("*.csproj")[0])
package_netcore_glob = glob.glob("*.csproj")
if os.path.isfile(package_json_file):
runtime_details_dict['language'] = NODE_RUNTIME_NAME
runtime_details_dict['file_loc'] = package_json_file
runtime_details_dict['default_sku'] = 'S1'
elif os.path.isfile(package_netcore_file):
elif package_netcore_glob:
package_netcore_file = os.path.join(src_path, package_netcore_glob[0])
runtime_details_dict['language'] = NETCORE_RUNTIME_NAME
runtime_details_dict['file_loc'] = package_netcore_file
runtime_details_dict['default_sku'] = 'F1'
Expand All @@ -138,7 +139,6 @@ def parse_netcore_version(file_path):
def parse_node_version(file_path):
import json
import re
version_detected = ['0.0']
with open(file_path) as data_file:
data = []
for d in find_key_in_json(json.load(data_file), 'node'):
Expand All @@ -148,7 +148,7 @@ def parse_node_version(file_path):
# reduce the version to '6.0' from '6.0.0'
data.append(c[:3])
version_detected = sorted(data, key=float, reverse=True)
return version_detected
return version_detected or ['0.0']


def detect_netcore_version_tocreate(detected_ver):
Expand Down

0 comments on commit bfd7a70

Please sign in to comment.