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

Working dir #53

Closed
satazor opened this issue Feb 10, 2013 · 7 comments
Closed

Working dir #53

satazor opened this issue Feb 10, 2013 · 7 comments

Comments

@satazor
Copy link
Member

satazor commented Feb 10, 2013

At the moment, all operations made within tasks are relative to where automaton runs.
Deep tasks have to use __dirname to perform operations with files referenced relatively. While this is an issue, only task devs will have to worry about it. I think we shouldn't do any magic regarding this.
Still project level autofiles, specially the ones located in tasks/ folder will suffer from this problem. If they try to specify files to cp, they will have to specify it relative to the project directory and not relative to the task itself.

Grunt makes the working directory relative to the gruntfile. I think that we should do the same, but we would have to do process.chdir. This is not actually good when automaton is being used programatically, unless we document it well or we spawn a fork to actually run automaton tasks.

@marcooliveira
Copy link
Member

I think we should keep in mind that this is still nodejs, and users know that any operation is based on the cwd. If this is not the desired behaviour, users can use the filter to do whatever they need to the paths. I'm open to discussion, but I still haven't seen a strong reason why we should be making magic.

@satazor
Copy link
Member Author

satazor commented Feb 11, 2013

@marcooliveira The problem is that project level tasks usually use relative references. The process.cwd() is usually the project root directory but if one tries to do cd tasks && automaton some_task.js, then strange things might happen.
Grunt makes the process.cwd() always the path of the gruntfile (think of it as our root autofile) which solves this issue.

@marcooliveira
Copy link
Member

What if the user tries to run automaton mkdir test? What would make sense to you? In this case, the autofile is within automaton itself, and if we make the autofile location the working dir, then the user will have created a test folder inside automaton, instead on the actual current working dir. This is a bit confusing.

@satazor
Copy link
Member Author

satazor commented Feb 12, 2013

I see your point. What about making an attribute of the task itself, living next to name and description. Grunt actually makes this a config option, called base.

@marcooliveira
Copy link
Member

Although that solves the issue, might lead to inconsistencies in task behaviour, since some developers might use __dirname, other process.cwd(). This issue is only real when a user does something, like you said, cd tasks && automaton some_task.js. cd is change dir, so the user is effectively changing the working dir. If he meant to run the task from the current dir, he should have done automaton tasks/some_task.js.

My opinion on this, is that this is nodejs, and people need to understand that they are running nodejs, not some magic code. If they need a stronger way to reference a file, without any annoyance of relative paths, they can always use absolute paths.

I'm still open to discuss this further, but haven't seen any strong reason why we should do something else.

@satazor
Copy link
Member Author

satazor commented Feb 14, 2013

This kind of issues will be mitigated with #30. We can reopen this if necessary later on. Right @marcooliveira ?

@marcooliveira
Copy link
Member

Yep! Fine with me, don't see this as a real issue yet. Let's wait for some feedback from the community, and see if it applies. Closing for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants