|
4 | 4 | importos |
5 | 5 | importshutil |
6 | 6 | importsubprocess |
7 | | -importsys |
8 | 7 | importtarfile |
9 | 8 | importtempfile |
10 | 9 | importurllib.request |
11 | 10 |
|
12 | 11 | BASE_URL="https://github.com/nodejs/gyp-next/archive/" |
13 | 12 | CHECKOUT_PATH=os.path.dirname(os.path.realpath(__file__)) |
14 | | -CHECKOUT_GYP_PATH=os.path.join(CHECKOUT_PATH, 'gyp') |
| 13 | +CHECKOUT_GYP_PATH=os.path.join(CHECKOUT_PATH, "gyp") |
15 | 14 |
|
16 | 15 | parser=argparse.ArgumentParser() |
17 | 16 | parser.add_argument("tag", help="gyp tag to update to") |
|
21 | 20 |
|
22 | 21 | changed_files=subprocess.check_output(["git", "diff", "--name-only"]).strip() |
23 | 22 | ifchanged_files: |
24 | | -raiseException("Can't update gyp while you have uncommitted changes in node-gyp") |
| 23 | +raiseException("Can't update gyp while you have uncommitted changes in node-gyp") |
25 | 24 |
|
26 | 25 | withtempfile.TemporaryDirectory() astmp_dir: |
27 | | -tar_file=os.path.join(tmp_dir, 'gyp.tar.gz') |
28 | | -unzip_target=os.path.join(tmp_dir, 'gyp') |
29 | | -withopen(tar_file, 'wb') asf: |
30 | | -print("Downloading gyp-next@"+args.tag+" into temporary directory...") |
31 | | -print("From: "+tar_url) |
32 | | -withurllib.request.urlopen(tar_url) asin_file: |
33 | | -f.write(in_file.read()) |
34 | | - |
35 | | -print("Unzipping...") |
36 | | -withtarfile.open(tar_file, "r:gz") astar_ref: |
37 | | -tar_ref.extractall(unzip_target) |
38 | | - |
39 | | -print("Moving to current checkout ("+CHECKOUT_PATH+")...") |
40 | | -ifos.path.exists(CHECKOUT_GYP_PATH): |
41 | | -shutil.rmtree(CHECKOUT_GYP_PATH) |
42 | | -shutil.move(os.path.join(unzip_target, os.listdir(unzip_target)[0]), CHECKOUT_GYP_PATH) |
| 26 | +tar_file=os.path.join(tmp_dir, "gyp.tar.gz") |
| 27 | +unzip_target=os.path.join(tmp_dir, "gyp") |
| 28 | +withopen(tar_file, "wb") asf: |
| 29 | +print("Downloading gyp-next@"+args.tag+" into temporary directory...") |
| 30 | +print("From: "+tar_url) |
| 31 | +withurllib.request.urlopen(tar_url) asin_file: |
| 32 | +f.write(in_file.read()) |
| 33 | + |
| 34 | +print("Unzipping...") |
| 35 | +withtarfile.open(tar_file, "r:gz") astar_ref: |
| 36 | +tar_ref.extractall(unzip_target) |
| 37 | + |
| 38 | +print("Moving to current checkout ("+CHECKOUT_PATH+")...") |
| 39 | +ifos.path.exists(CHECKOUT_GYP_PATH): |
| 40 | +shutil.rmtree(CHECKOUT_GYP_PATH) |
| 41 | +shutil.move( |
| 42 | +os.path.join(unzip_target, os.listdir(unzip_target)[0]), CHECKOUT_GYP_PATH |
| 43 | + ) |
43 | 44 |
|
44 | 45 | subprocess.check_output(["git", "add", "gyp"], cwd=CHECKOUT_PATH) |
45 | 46 | subprocess.check_output(["git", "commit", "-m", "gyp: update gyp to "+args.tag]) |
0 commit comments