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

Usage from within a Beak script & uninstallability? #20

Closed
Jeehut opened this issue Apr 29, 2019 · 2 comments
Closed

Usage from within a Beak script & uninstallability? #20

Jeehut opened this issue Apr 29, 2019 · 2 comments

Comments

@Jeehut
Copy link

Jeehut commented Apr 29, 2019

I'm just trying to use Komondor from within a Beak script, since there you can also specify SwiftPM dependencies and run them separately from the Package.swift file. I'm already confused because of #18 and #19, but what I also don't understand is how the definition of a config parameter leads to Komondor to know what things to run? Does that mean that Komondor is parsing the Package.swift file and trying to find a PackageConfig object there, I'm really confused about how this works.

Here's what I'm trying at the moment using Beak:

#!/usr/bin/env beak run --path

// MARK: - Script Dependencies
// beak: shibapm/Komondor @ .upToNextMajor(from: "1.0.4")

import Foundation
import PackageConfig

// MARK: - Runnable Tasks
/// Registers git hooks for the project to ensure you get notified of potential issues e.g. before committing.
public func register() throws {
    let config = PackageConfig([
        "komondor": [
            "pre-commit": ["bartycrouch lint --fail-on-warnings", "swiftlint lint --strict --quiet"]
        ]
    ])

    // TODO: make sure the `config` actually is being used by `kommondor install`, but how?
}

/// Unregisters any registered git hooks.
public func unregister() throws {
    let config = PackageConfig(["komondor": []])
    // TODO: make sure the `config` actually is being applied by `kommondor install` and updates previous hooks, but how?
}

My goal is to have both a hooks register and a hooks unregister command setup which developers who checkout the project can run in order to – well, register or unregister all hooks I might define within that file. Also, how does Komondor behave when I change my hooks and re-run kommondor install, does it remove all removed hooks and also ensure no duplicates appear in the final configured hooks?

@Jeehut
Copy link
Author

Jeehut commented Apr 29, 2019

Please note that I found a much easier way to configure git hooks in my project setup, so I won't need this feature, personally. Feel free to close it if you feel like you don't want it.
Sorry for reporting it first, then not actually needing it. 😅

If anyone is curious how I got it working using Beak, checkout our hooks.swift file.

@orta
Copy link
Member

orta commented Apr 29, 2019

I don't really know much about beak, the install script installs generic hooks which look in your config to decide if they should run or not. I think you miss the value of Komondor: it has a central & consistent way to do git hooks and is only responsible for running whatever is defined in your package.swift.

I'm not too suer what you're trying to do with the script in the OP, but I'm happy you found a way 👍

@orta orta closed this as completed Apr 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants