import plistlib
import shutil
import json
-import re
-from os.path import join, basename
+from os.path import join
+
def xp_filename(basename):
return re.sub('["<>*?|\\\\]', "_",
basename.replace("/", "-").replace(":", "."))
+
def versionify(version):
return ".".join(filter(lambda x: x.isdigit(),
re.split("[-+.]", version))[:3])
+
def main(nwdir, nwpackage):
if not os.path.isdir(nwdir):
raise StandardError("input (%r) is not a directory" % nwdir)
nwzip = zipfile.ZipFile(nwpackage)
icnss = filter(lambda f: f.lower().endswith(".icns"),
- nwzip.namelist())
+ nwzip.namelist())
package = json.load(nwzip.open("package.json"))
- app = join(nwdir, "node-webkit.app")
+ app = join(nwdir, "nwjs.app")
title = package["window"]["title"]
exe = package["name"].split(".")[-1]
plist = dict(
plist["CFBundleIconFile"] = icnss[0]
plistlib.writePlist(plist, join(app, "Contents/Info.plist"))
exedir = join(app, "Contents", "MacOS")
- shutil.move(join(exedir, "node-webkit"), join(exedir, exe))
+ shutil.move(join(exedir, "nwjs"), join(exedir, exe))
shutil.copy(nwpackage, join(app, "Contents", "Resources", "app.nw"))
shutil.move(app, join(app, "..", xp_filename(title) + ".app"))
if __name__ == "__main__":
import sys
main(*sys.argv[1:])
-