Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete packages. #338

Merged
merged 9 commits into from
May 31, 2017
16 changes: 16 additions & 0 deletions lib/sync-settings.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ SyncSettings =
if atom.config.get('sync-settings.syncPackages')
callbackAsync = true
@installMissingPackages JSON.parse(file.content), cb
@uninstallRedundantPackages JSON.parse(file.content), cb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is a great feature I think it is not necessarily what all users want. Therefore I think this should be an option in the settings which defaults to false to maintain the current behavior.


when 'keymap.cson'
fs.writeFileSync atom.keymaps.getUserKeymapPath(), file.content if atom.config.get('sync-settings.syncKeymap')
Expand Down Expand Up @@ -300,6 +301,21 @@ SyncSettings =
console.debug "config.set #{keyPath[1...]}=#{value}"
atom.config.set keyPath[1...], value

uninstallRedundantPackages: (packages, cb) ->
available_packages = @getPackages()
redundant_packages = []
Copy link
Contributor

@dirk-thomas dirk-thomas Mar 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be obsolete_packages.

for pkg in available_packages
available_package = (p for p in packages when p.name is pkg.name)
if available_package.length is 0
redundant_packages.push(pkg)
if redundant_packages.length is 0
atom.notifications.addInfo "Sync-settings: no packages to remove"
return cb?()
else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the else case the cb doesn't seem to get called anywhere?

for pkg in redundant_packages
packageManager = new PackageManager()
packageManager.uninstall pkg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call of uninstall should also pass a callback to inform the user about progress / success / failure of the command.


installMissingPackages: (packages, cb) ->
available_packages = @getPackages()
missing_packages = []
Expand Down