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

change to directory of project path #86

Open
alanktwong opened this issue Sep 6, 2024 · 1 comment
Open

change to directory of project path #86

alanktwong opened this issue Sep 6, 2024 · 1 comment

Comments

@alanktwong
Copy link

alanktwong commented Sep 6, 2024

If I already have a mani.yaml configured for multiple projects, I would like to write a custom task that will change my current CLI (in my case darwin or linux) to the project path.

projects:
  example:
    path: .
    desc: A mani example

  pinto:
    path: frontend/pinto
    url: https://github.com/alajmo/pinto.git
    desc: A vim theme editor
    tags: [frontend, node]

tasks:
  go-here:
    desc: go to project path
    target:
      cwd: true  # what does this do?
    cmd: pushd "$(pwd)"

I would like mani run go-here -p pinto to change the current working directory of my shell to ./frontend/pinto

Testing this I always seem to return to working directory from where I executed mani.

One of the reasons driving this is that many multi-project development teams have repo-specific dependencies such as .npmrc, .python-version, .sdkmanrc which only kick in of the current working directory is that of the project.

@alanktwong alanktwong changed the title change to directory to project path change to directory of project path Sep 7, 2024
@alajmo
Copy link
Owner

alajmo commented Sep 7, 2024

You can read the manual here or man mani.

# List of targets [optional]
targets:
  default:
    # Target all projects
    all: false

    # Target current working directory project
    cwd: false

    # Specify projects via project name
    projects: []

    # Specify projects via project path
    paths: []

    # Specify projects via project tags
    tags: []

cwd means to target the project you are standing in.

if you stand in /pinto it will target pinto, if you stand in root, it will target /example. This is mainly to avoid typing mani run <task> -p <project>.

Also note, pushd is not available in sh, which is the shell selected by default. If you want to change the default shell add shell: bash (or zsh, etc.):

shell: bash

projects:
  example:
    path: .
    desc: A mani example

  pinto:
    path: frontend/pinto
    url: https://github.com/alajmo/pinto.git
    desc: A vim theme editor
    tags: [frontend, node]

tasks:
  go-here:
    desc: go to project path
    target:
      cwd: true  # what does this do?
    cmd: pushd "$(pwd)"

If you mean you want to change your current shell's directory, that's not really possible it seems.

https://stackoverflow.com/questions/46028707/how-to-change-the-current-directory-in-go

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