mirror of
https://github.com/lifegpc/bookdownload.git
synced 2026-06-06 05:38:46 +08:00
Add support to create crx file
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
dist/
|
dist/
|
||||||
*.crx
|
*.crx
|
||||||
|
*.pem
|
||||||
|
*.zip
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from zipfile import ZipFile, ZIP_DEFLATED
|
from zipfile import ZipFile, ZIP_DEFLATED
|
||||||
import os
|
import os
|
||||||
|
from crx3 import creator
|
||||||
|
|
||||||
NEED_PACKED = [
|
NEED_PACKED = [
|
||||||
'dist',
|
'dist',
|
||||||
@@ -10,7 +11,7 @@ NEED_PACKED = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
def pack():
|
def pack():
|
||||||
with ZipFile('bookdownload.crx', 'w', compression=ZIP_DEFLATED, compresslevel=9) as zip:
|
with ZipFile('bookdownload.zip', 'w', compression=ZIP_DEFLATED, compresslevel=9) as zip:
|
||||||
for item in NEED_PACKED:
|
for item in NEED_PACKED:
|
||||||
if not os.path.exists(item):
|
if not os.path.exists(item):
|
||||||
print(f'Warning: {item} does not exist, skipping.')
|
print(f'Warning: {item} does not exist, skipping.')
|
||||||
@@ -21,6 +22,8 @@ def pack():
|
|||||||
zip.write(os.path.join(foldername, filename))
|
zip.write(os.path.join(foldername, filename))
|
||||||
else:
|
else:
|
||||||
zip.write(item)
|
zip.write(item)
|
||||||
|
creator.create_crx_file('bookdownload.zip', 'bookdownload.pem', './bookdownload.crx')
|
||||||
|
os.remove('bookdownload.zip')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user