From f6f4ddaf78ef38dc0243d5bebfc2c137df8c7664 Mon Sep 17 00:00:00 2001 From: Eric MORAND Date: Thu, 1 Dec 2016 03:56:06 +0100 Subject: [PATCH] Fix issue #947 (#982) --- lib/index.js | 2 ++ test/base.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 74794aa8..a3d377b8 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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 }); diff --git a/test/base.js b/test/base.js index dac5084d..9c1eb4b4 100644 --- a/test/base.js +++ b/test/base.js @@ -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'], { @@ -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 () {