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

app.cwd points to original cwd when passing --cwd #947

Open
4 of 5 tasks
mootari opened this issue Jan 13, 2018 · 4 comments
Open
4 of 5 tasks

app.cwd points to original cwd when passing --cwd #947

mootari opened this issue Jan 13, 2018 · 4 comments

Comments

@mootari
Copy link
Contributor

mootari commented Jan 13, 2018

Prerequisites

  • Have you searched for existing issues (open and close) to see if the bug or feature request has already been reported?
  • If this is a bug report, are you running the latest version of Assemble? If not, please update to the latest version and verify that the issue still occurs before proceding.
  • Have you read the Contributing Guide? <-- Broken link
  • Have you reviewed the project readme (you might find advice about creating new issues)?
  • Are you creating an issue in the correct repository? (For example, if your issue is related to [grunt-assemble][] or [handlebars-helpers][], you will want to create the issue in that project).

Ready? Great! Please provide the following details:

version

0.24.3

description

When invoking assemble from the shell and passing the --cwd option, assemble correctly changes process.cwd to the specified directory, but app.cwd still returns the original cwd.

/dir/src/assemblefile.js

const app = require('assemble')();
// ...
module.exports = app;
# Note: /dir contains package.json
$ cd /dir
$ npx assemble --cwd=src

The problem appears to be that the original cwd gets cached. I had plastered breakpoints all over base-cwd/index.js but was unable to capture the first assignment. Whenever I got to break in either get or set, cached had already assigned the initial cwd.

@assemblebot
Copy link

@mootari Thanks for the issue! If you're reporting a bug, please be sure to include:

  • The version of assemble you are using.
  • Your assemblefile.js (This can be in a gist)
  • The commandline output. (Screenshot or gist is fine)
  • What you expected to happen instead.

If your issue is related to one of the following, please open an issue there:

  • grunt-assemble Issues with using assemble in grunt or the grunt-assemble library.
  • handlebars-helpers Issues with using handlebars helpers from the handlebars-helpers library.

@mootari
Copy link
Contributor Author

mootari commented Jan 13, 2018

Found the culprit. The initial cached value gets set to the pkgPath, triggered by base-cli-process/lib/fields/cwd.js when assemble enables the cli plugin.

@jonschlinkert
Copy link
Member

Have you read the Contributing Guide? <-- Broken link

Hmm, this probably means all or most of them are. I'm guessing our template is wrong.

Found the culprit. The initial cached value gets set to the pkgPath, triggered by base-cli-process/lib/fields/cwd.js when assemble enables the cli plugin.

great! want to do a pr? Sorry if you already have, I'm getting caught up...

@jonschlinkert
Copy link
Member

btw, I'm going to start working on 1.0 of assemble soon. One goal is to simplify some of that logic, but I'd also like to add some CLI commands. If you have any suggestions or requests we should get an issue started to discuss, thanks!

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

3 participants