mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	node cache: Don't shell out to yarn to get the version.
This can easily be done by just reading the package.json file and extracting the version value, just like we now do in install-node.
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
			
		||||
 | 
			
		||||
import os
 | 
			
		||||
import hashlib
 | 
			
		||||
import json
 | 
			
		||||
 | 
			
		||||
if False:
 | 
			
		||||
    from typing import Optional, List, IO, Tuple, Any
 | 
			
		||||
@@ -17,6 +18,7 @@ if 'TRAVIS' in os.environ:
 | 
			
		||||
 | 
			
		||||
NODE_MODULES_CACHE_PATH = os.path.join(ZULIP_SRV_PATH, 'zulip-npm-cache')
 | 
			
		||||
YARN_BIN = os.path.join(ZULIP_SRV_PATH, 'zulip-yarn/bin/yarn')
 | 
			
		||||
YARN_PACKAGE_JSON = os.path.join(ZULIP_SRV_PATH, 'zulip-yarn/package.json')
 | 
			
		||||
 | 
			
		||||
DEFAULT_PRODUCTION = False
 | 
			
		||||
 | 
			
		||||
@@ -39,7 +41,9 @@ def generate_sha1sum_node_modules(setup_dir=None, production=DEFAULT_PRODUCTION)
 | 
			
		||||
    if os.path.exists(YARN_LOCK_FILE_PATH):
 | 
			
		||||
        # For backwards compatibility, we can't assume yarn.lock exists
 | 
			
		||||
        sha1sum.update(subprocess_text_output(['cat', YARN_LOCK_FILE_PATH]).encode('utf8'))
 | 
			
		||||
    sha1sum.update(subprocess_text_output([YARN_BIN, '--version']).encode('utf8'))
 | 
			
		||||
    with open(YARN_PACKAGE_JSON, "r") as f:
 | 
			
		||||
        yarn_version = json.loads(f.read())['version']
 | 
			
		||||
        sha1sum.update(yarn_version.encode("utf8"))
 | 
			
		||||
    sha1sum.update(subprocess_text_output(['node', '--version']).encode('utf8'))
 | 
			
		||||
    yarn_args = get_yarn_args(production=production)
 | 
			
		||||
    sha1sum.update(''.join(sorted(yarn_args)).encode('utf8'))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user