@tacuchi/updater 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +15 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -781,6 +781,19 @@ function once(key, fn) {
|
|
|
781
781
|
function pipCmd() {
|
|
782
782
|
return process.platform === "win32" ? "pip" : "pip3";
|
|
783
783
|
}
|
|
784
|
+
function pipInvocation(python) {
|
|
785
|
+
return python ? { cmd: python, baseArgs: ["-m", "pip"] } : { cmd: pipCmd(), baseArgs: [] };
|
|
786
|
+
}
|
|
787
|
+
async function pythonModuleCmd() {
|
|
788
|
+
return once("pip:python", async () => {
|
|
789
|
+
const candidates = process.platform === "win32" ? ["python", "py", "python3"] : ["python3", "python"];
|
|
790
|
+
for (const c of candidates) {
|
|
791
|
+
const probe = await execCommand(c, ["-m", "pip", "--version"], 5e3);
|
|
792
|
+
if (probe.exitCode === 0) return c;
|
|
793
|
+
}
|
|
794
|
+
return null;
|
|
795
|
+
});
|
|
796
|
+
}
|
|
784
797
|
function parsePipOutdated(stdout) {
|
|
785
798
|
try {
|
|
786
799
|
const data = JSON.parse(stdout);
|
|
@@ -817,15 +830,15 @@ var pip = {
|
|
|
817
830
|
escapeHatch: {
|
|
818
831
|
listOutdated,
|
|
819
832
|
async *upgrade(packages, ctx) {
|
|
820
|
-
const cmd = pipCmd();
|
|
821
833
|
yield { type: "phase", phase: "upgrading", message: "Actualizando pip..." };
|
|
822
834
|
const flags = await pep668Flags();
|
|
823
835
|
if (flags.length) yield { type: "log", message: "Entorno PEP 668: usando --break-system-packages" };
|
|
836
|
+
const { cmd, baseArgs } = pipInvocation(await pythonModuleCmd());
|
|
824
837
|
const before = await listOutdated();
|
|
825
838
|
const target = packages && packages.length ? packages : before.map((p) => p.name);
|
|
826
839
|
const commands = [];
|
|
827
840
|
if (target.length) {
|
|
828
|
-
const args2 = ["install", "--user", "--upgrade", ...flags, ...target];
|
|
841
|
+
const args2 = [...baseArgs, "install", "--user", "--upgrade", ...flags, ...target];
|
|
829
842
|
yield { type: "log", message: `${cmd} ${args2.join(" ")}` };
|
|
830
843
|
const rec = yield* runStream(cmd, args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
|
|
831
844
|
commands.push(rec);
|