more logic
This commit is contained in:
parent
fb6187f502
commit
c496725c37
6
index.ts
6
index.ts
@ -55,11 +55,7 @@ function parseArgs() {
|
|||||||
.choices(["auto", "google", "yandex"])
|
.choices(["auto", "google", "yandex"])
|
||||||
.default("auto")
|
.default("auto")
|
||||||
)
|
)
|
||||||
.option(
|
.option("-c, --cookie [value]", "google.com cookie header value")
|
||||||
"-c, --cookie [path]",
|
|
||||||
"google.com cookie header value file path",
|
|
||||||
(val) => fs.readFileSync(resolvePath(val, ["txt"])).toString("utf-8")
|
|
||||||
)
|
|
||||||
.argument("image <path>", "input image file path", (val) =>
|
.argument("image <path>", "input image file path", (val) =>
|
||||||
resolvePath(val, ["jpg", "jpeg", "png"])
|
resolvePath(val, ["jpg", "jpeg", "png"])
|
||||||
)
|
)
|
||||||
|
|||||||
27
itame.py
27
itame.py
@ -3,6 +3,16 @@ from pathlib import Path
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
subprocess.run(
|
||||||
|
["bun", "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
|
||||||
|
)
|
||||||
|
except FileNotFoundError:
|
||||||
|
print("bun not found, please run the following command to install it:")
|
||||||
|
print('powershell -c "irm bun.sh/install.ps1|iex"')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
file_dir = Path(__file__).parent
|
file_dir = Path(__file__).parent
|
||||||
itame_vendor_dir = file_dir / "itame"
|
itame_vendor_dir = file_dir / "itame"
|
||||||
|
|
||||||
@ -10,19 +20,18 @@ if not itame_vendor_dir.exists():
|
|||||||
print("script must be placed in the parent directory of the vendor itame directory")
|
print("script must be placed in the parent directory of the vendor itame directory")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
os.chdir(itame_vendor_dir)
|
node_modules_dir = itame_vendor_dir / "node_modules"
|
||||||
|
entrypoint = itame_vendor_dir / "index.ts"
|
||||||
|
|
||||||
if not os.path.exists(".initialized"):
|
if not node_modules_dir.exists():
|
||||||
p = subprocess.run(["powershell", "-c", "irm bun.sh/install.ps1|iex"])
|
old_dir = os.getcwd()
|
||||||
if p.returncode != 0:
|
os.chdir(itame_vendor_dir)
|
||||||
print("failed to install bun")
|
|
||||||
sys.exit(1)
|
|
||||||
open(".initialized", "w").close()
|
|
||||||
|
|
||||||
if not os.path.exists("node_modules"):
|
|
||||||
p = subprocess.run(["bun", "i"])
|
p = subprocess.run(["bun", "i"])
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
print("failed to install node modules")
|
print("failed to install node modules")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
subprocess.run(["bun", "run", "index.ts"] + sys.argv[1:])
|
os.chdir(old_dir)
|
||||||
|
|
||||||
|
subprocess.run(["bun", "run", str(entrypoint)] + sys.argv[1:])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user