Skip to content

Commit

Permalink
Merge pull request #103 from pulsar-edit/stop-pinging-backend-for-uni…
Browse files Browse the repository at this point in the history
…nstalls

src: Stop pinging backend during package uninstalls
  • Loading branch information
DeeDeeG authored Dec 13, 2023
2 parents 13fb284 + afa059b commit 6ea5aa0
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions src/uninstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ const async = require('async');
const CSON = require('season');
const yargs = require('yargs');

const auth = require('./auth');
const Command = require('./command');
const config = require('./apm');
const fs = require('./fs');
const request = require('./request');

module.exports =
class Uninstall extends Command {
Expand Down Expand Up @@ -37,24 +35,6 @@ Delete the installed package(s) from the ~/.pulsar/packages directory.\
}
}

async registerUninstall({packageName, packageVersion}) {
if (!packageVersion) { return; }

try {
const token = await auth.getToken();
const requestOptions = {
url: `${config.getAtomPackagesUrl()}/${packageName}/versions/${packageVersion}/events/uninstall`,
json: true,
headers: {
authorization: token
}
};
return new Promise((resolve, _reject) => void request.post(requestOptions, (_error, _response, _body) => resolve()));
} catch (error) {
return error; // error as value here
}
}

async run(options) {
options = this.parseOptions(options.commandArgs);
const packageNames = this.packageNamesFromArgv(options.argv);
Expand All @@ -66,7 +46,6 @@ Delete the installed package(s) from the ~/.pulsar/packages directory.\
const packagesDirectory = path.join(config.getAtomDirectory(), 'packages');
const devPackagesDirectory = path.join(config.getAtomDirectory(), 'dev', 'packages');

const uninstallsToRegister = [];
let uninstallError = null;

for (let packageName of Array.from(packageNames)) {
Expand All @@ -82,9 +61,6 @@ Delete the installed package(s) from the ~/.pulsar/packages directory.\
if (fs.existsSync(packageManifestPath)) {
const packageVersion = this.getPackageVersion(packageDirectory);
fs.removeSync(packageDirectory);
if (packageVersion) {
uninstallsToRegister.push({packageName, packageVersion});
}
} else if (!options.argv.hard) {
throw new Error(`No package.json found at ${packageManifestPath}`);
}
Expand All @@ -107,7 +83,6 @@ Delete the installed package(s) from the ~/.pulsar/packages directory.\
}
}

await async.eachSeries(uninstallsToRegister, (data, errorHandler) =>void this.registerUninstall(data).then(errorHandler));
return uninstallError; // both error and lack of error, as return value atm
}
}

0 comments on commit 6ea5aa0

Please sign in to comment.