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

Expose the directory where the generator is being executed #982

Merged
merged 1 commit into from Dec 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/index.js
Expand Up @@ -115,6 +115,8 @@ var Base = module.exports = function Base(args, options) {
this.log = this.env.adapter.log;

// determine the app root
this.contextRoot = this.env.cwd;

var rootPath = findUp.sync('.yo-rc.json', {
cwd: this.env.cwd
});
Expand Down
4 changes: 3 additions & 1 deletion test/base.js
Expand Up @@ -53,7 +53,8 @@ describe('Base', function () {
describe('constructor', function () {
it('set the CWD where `.yo-rc.json` is found', function () {
var projectDir = path.join(__dirname, 'fixtures/dummy-project');
process.chdir(path.join(projectDir, 'subdir'));
var subdir = path.join(projectDir, 'subdir');
process.chdir(subdir);
this.env.cwd = process.cwd();

var dummy = new this.Dummy(['foo'], {
Expand All @@ -63,6 +64,7 @@ describe('Base', function () {

assert.equal(process.cwd(), projectDir);
assert.equal(dummy.destinationPath(), projectDir);
assert.equal(dummy.contextRoot, subdir);
});

it('use the environment options', function () {
Expand Down