Skip to content

Commit 8a99ae8

Browse files
authored
Use zip_cmd() and unzip_cmd() in update_node.py as well. (#1471)
This way update_node.py can be called on Windows host machines as well.
1 parent eda31dc commit 8a99ae8

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

scripts/update_node.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import sys
1717
import os
1818
import shutil
19+
from zip import unzip_cmd, zip_cmd
1920

2021
version = '18.20.3'
2122
base = 'https://nodejs.org/dist/latest-v18.x/'
@@ -38,13 +39,13 @@
3839
urllib.request.urlretrieve(download_url, filename)
3940

4041
if '-win-' in suffix:
41-
subprocess.check_call(['unzip', '-q', filename])
42+
subprocess.check_call(unzip_cmd() + [filename])
4243
dirname = os.path.splitext(os.path.basename(filename))[0]
4344
shutil.move(dirname, 'bin')
4445
os.mkdir(dirname)
4546
shutil.move('bin', dirname)
4647
os.remove(filename)
47-
subprocess.check_call(['zip', '-rq', filename, dirname])
48+
subprocess.check_call(zip_cmd() + [filename, dirname])
4849
shutil.rmtree(dirname)
4950

5051
if '--upload' in sys.argv:

scripts/update_python.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import subprocess
3131
import sys
3232
from subprocess import check_call
33+
from zip import unzip_cmd, zip_cmd
3334

3435
version = '3.9.2'
3536
major_minor_version = '.'.join(version.split('.')[:2]) # e.g. '3.9.2' -> '3.9'
@@ -44,22 +45,6 @@
4445
upload_base = 'gs://webassembly/emscripten-releases-builds/deps/'
4546

4647

47-
def unzip_cmd():
48-
# Use 7-Zip if available (https://www.7-zip.org/)
49-
sevenzip = os.path.join(os.getenv('ProgramFiles', ''), '7-Zip', '7z.exe')
50-
if os.path.isfile(sevenzip):
51-
return [sevenzip, 'x']
52-
# Fall back to 'unzip' tool
53-
return ['unzip', '-q']
54-
55-
56-
def zip_cmd():
57-
# Use 7-Zip if available (https://www.7-zip.org/)
58-
sevenzip = os.path.join(os.getenv('ProgramFiles', ''), '7-Zip', '7z.exe')
59-
if os.path.isfile(sevenzip):
60-
return [sevenzip, 'a', '-mx9']
61-
# Fall back to 'zip' tool
62-
return ['zip', '-rq']
6348

6449

6550
def make_python_patch():

scripts/zip.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os
2+
3+
def unzip_cmd():
4+
# Use 7-Zip if available (https://www.7-zip.org/)
5+
sevenzip = os.path.join(os.getenv('ProgramFiles', ''), '7-Zip', '7z.exe')
6+
if os.path.isfile(sevenzip):
7+
return [sevenzip, 'x']
8+
# Fall back to 'unzip' tool
9+
return ['unzip', '-q']
10+
11+
12+
def zip_cmd():
13+
# Use 7-Zip if available (https://www.7-zip.org/)
14+
sevenzip = os.path.join(os.getenv('ProgramFiles', ''), '7-Zip', '7z.exe')
15+
if os.path.isfile(sevenzip):
16+
return [sevenzip, 'a', '-mx9']
17+
# Fall back to 'zip' tool
18+
return ['zip', '-rq']

0 commit comments

Comments
 (0)