From a2c5b141e0535b9713cc52888b2422a9f4aed21c Mon Sep 17 00:00:00 2001 From: Marcus Date: Tue, 30 Oct 2018 21:21:32 -0400 Subject: [PATCH] moved things --- .installerLocation | 1 + bin/python.js | 5 +++-- package-lock.json | 7 ++++++- package.json | 4 +++- scripts/clean.js | 1 + postinstall.js => scripts/postinstall.js | 0 scripts/uninstall.js | 10 ++++++++++ example.py => tests/example.py | 0 uninstall.js | 6 ------ {Download-Latest-Python => util}/downloadpython.js | 5 +++-- pip.py => util/pip.py | 0 11 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 .installerLocation create mode 100644 scripts/clean.js rename postinstall.js => scripts/postinstall.js (100%) create mode 100644 scripts/uninstall.js rename example.py => tests/example.py (100%) delete mode 100644 uninstall.js rename {Download-Latest-Python => util}/downloadpython.js (96%) rename pip.py => util/pip.py (100%) diff --git a/.installerLocation b/.installerLocation new file mode 100644 index 0000000..46f8f3b --- /dev/null +++ b/.installerLocation @@ -0,0 +1 @@ +python-3.7.1.exe \ No newline at end of file diff --git a/bin/python.js b/bin/python.js index 6f162bf..3a203e2 100644 --- a/bin/python.js +++ b/bin/python.js @@ -2,8 +2,9 @@ const path = require('path'); let pythonPath = path.resolve(__dirname, '..', 'Python', 'python.exe'); +// const versions = require('./') -// console.log(process.argv); +let args = process.argv.slice(2); -require('child_process').spawn(pythonPath, [], {stdio: 'inherit'}); +require('child_process').spawn(pythonPath, args, {stdio: 'inherit'}); diff --git a/package-lock.json b/package-lock.json index ccf8067..3e99f07 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "portapy", - "version": "0.0.1", + "version": "0.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -217,6 +217,11 @@ "mime-db": "~1.37.0" } }, + "minimist": { + "version": "1.2.0", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + }, "oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", diff --git a/package.json b/package.json index aed7ffc..77d1a65 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "postinstall": "node postinstall.js", - "preuninstall": "node uninstall.js" + "preuninstall": "node uninstall.js", + "clean": "node clean.js" }, "bin": { "python": "bin/python.js" @@ -21,6 +22,7 @@ "url": "https://github.com/marcus13345/pythonjs/issues" }, "dependencies": { + "minimist": "^1.2.0", "python": "0.0.4", "request": "2.88.0" }, diff --git a/scripts/clean.js b/scripts/clean.js new file mode 100644 index 0000000..43cb185 --- /dev/null +++ b/scripts/clean.js @@ -0,0 +1 @@ +// const fs = \ No newline at end of file diff --git a/postinstall.js b/scripts/postinstall.js similarity index 100% rename from postinstall.js rename to scripts/postinstall.js diff --git a/scripts/uninstall.js b/scripts/uninstall.js new file mode 100644 index 0000000..1f999e4 --- /dev/null +++ b/scripts/uninstall.js @@ -0,0 +1,10 @@ +const path = require('path'); +const fs = require('fs'); + +let installerFilename = fs.readFileSync('.installerLocation').toString(); + +let pythonPath = path.resolve(__dirname, 'Python-Installer', installerFilename); + +require('child_process').execSync(`${pythonPath} /passive /uninstall`, { + stdio: 'inherit' +}); \ No newline at end of file diff --git a/example.py b/tests/example.py similarity index 100% rename from example.py rename to tests/example.py diff --git a/uninstall.js b/uninstall.js deleted file mode 100644 index 0887044..0000000 --- a/uninstall.js +++ /dev/null @@ -1,6 +0,0 @@ -const path = require('path'); -let pythonPath = path.resolve(__dirname, 'Python-Installer', 'python-3.7.1.exe'); - -require('child_process').execSync(`${pythonPath} /passive /uninstall`, { - stdio: 'inherit' -}); \ No newline at end of file diff --git a/Download-Latest-Python/downloadpython.js b/util/downloadpython.js similarity index 96% rename from Download-Latest-Python/downloadpython.js rename to util/downloadpython.js index af139c7..a98ffc8 100644 --- a/Download-Latest-Python/downloadpython.js +++ b/util/downloadpython.js @@ -20,6 +20,9 @@ async function download() { try { fs.mkdirSync('Python'); } catch(e) {'';} + try { + fs.writeFileSync('.installerLocation', filename); + } catch(e) {'';} // let installSettings = fs.readFileSync('unattend.xml'); let out_file = `Python-Installer/${filename}` @@ -30,7 +33,6 @@ async function download() { uri: url, encoding: null }, function (error, response, body) { - console.log(typeof body); fs.writeFileSync(out_file, body, {}); resolve(); }); @@ -86,7 +88,6 @@ function getPythonDownloadLink() { let current_download_end = body.indexOf('">', current_download_start); let current_download = body.substring(current_download_start, current_download_end); - console.log(current_download); let url = current_download; resolve(url); diff --git a/pip.py b/util/pip.py similarity index 100% rename from pip.py rename to util/pip.py